This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"container/heap" | |
"fmt" | |
) | |
type Count struct { | |
arrayRef int | |
indexRef int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def height_dfs(root): | |
stack = [(root, 0)] | |
total_height = 0 | |
while stack: | |
current_node, height = stack.pop() | |
total_height = max(total_height, height) | |
if current_node.left: | |
stack.append((current_node.left, height + 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LIMIT = 1000000 | |
def unmaskNumber(number): | |
if number <= -LIMIT: | |
number = number + LIMIT | |
elif number > LIMIT: | |
number = number - LIMIT | |
return number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type node struct { | |
Value int | |
Left *node | |
Right *node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
) | |
type hash struct { | |
vector []interface{} | |
length int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
) | |
type node struct { | |
value int | |
next *node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
) | |
type node struct { | |
value int | |
next *node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example: | |
duplicates([1, 21, -4, 103, 21, 4, 1]); | |
result = [1, 21] | |
*/ | |
function find_duplicates(arr) { | |
const duplicates = {}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example: | |
(1, 1) -> (1, 2) -> (2, 2) | |
(1, 1) -> (2, 1) -> (2, 2) | |
*/ | |
function chessboardTraveling(x, y, a, b) { | |
let count = 0; | |
const queue = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrackerError(Exception): | |
pass | |
class TrackerMethodNotImplemented(TrackerError): | |
pass | |
class StackTracker(object): | |
def __init__(self, limit, items = None): |