tvl-depot/scratch/facebook
William Carroll 9549dbb266 Update BFS impls
I've subtly been implementing breadth-first traversals in graphs
incorrectly. The change is subtle, but updating `seen` needs to happen
immediately after queuing an item.

The results will remain the same, but the runtimes will differ dramatically. I
didn't notice this until I attempted to complete LeetCode's "count islands"
challenge, and LeetCode rejected my solution because it could not finish before
timing out. After looking at other candidates' solutions and comparing them to
mine, I couldn't see any difference... except for this subtle difference.

This SO answer provides a helpful explanation:
https://stackoverflow.com/questions/45623722/marking-node-as-visited-on-bfs-when-dequeuing

The take-away lesson here is to always call `seen.add(..)` immediately after
enqueuing.
2020-11-23 23:21:20 +00:00
..
hard Re-implement suffix_tree function 2020-11-19 21:12:36 +00:00
interview-cake Solve "cafe order checker" (again) 2020-11-21 16:31:53 +00:00
moderate Solve "find pairs for sum" 2020-11-16 17:12:05 +00:00
parsing Document subset of BNF for regex engine 2020-11-13 16:55:39 +00:00
recursion-and-dynamic-programming Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
anglocize-int.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
balanced-binary-tree.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
breakfast-generator.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
bst-checker.py Refactor existing bst-checker implementation 2020-11-21 14:14:50 +00:00
cafe-order-checker.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
cake_thief.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
camping-knapsack.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
coin.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
count-islands.py Update BFS impls 2020-11-23 23:21:20 +00:00
delete-node.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
dijkstras.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
edit-distance.py Implement the Levenstein "edit distance" algorithm 2020-11-20 21:59:18 +00:00
evaluator.hs Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
evaluator.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
find-duplicate-beast-mode.py Solve "find duplicate" using a graph 2020-11-21 13:35:05 +00:00
find-duplicate-optimize-for-space.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
find-rotation-point.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
find-unique-int-among-duplicates.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
graph-coloring.py Update BFS impls 2020-11-23 23:21:20 +00:00
heap.py Partially implement a Heap 2020-11-14 14:08:58 +00:00
highest-product-of-3.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
infix-to-postfix.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
inflight-entertainment.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
intersecting-linked-lists.py Find the intersection (if any) between two linked lists 2020-11-15 17:42:44 +00:00
knapsack-faq.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
kth-to-last-node-in-singly-linked-list.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
language.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
language2.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
largest-contiguous-sum.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
largest-stack.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
linked-list-cycles.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
linked_list.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
london-knapsack.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
longest-common-substring.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
merge-sorted-arrays.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
merging-ranges.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
mesh-message.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
move-zeroes-to-end.py Add another solution to the "move zeroes to end" problem 2020-11-16 17:13:03 +00:00
mst.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
n-queens.py Solve N queens 2020-11-13 16:56:02 +00:00
nearby-words.py Solve "nearby words" function 2020-11-16 17:17:28 +00:00
node.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
nth-fibonacci.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
onsite.txt Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
permutation-palindrome.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
polynomial-rolling-hash.py Prefer mutative variant of delete for HashTable 2020-11-16 17:13:39 +00:00
product-of-all-other-numbers.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
queue-two-stacks.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
rabin-karp.py Implement the Rabin Karp string matching algorithm 2020-11-16 17:14:08 +00:00
recursive-string-permutations.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
reverse-linked-list.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
reverse-string-in-place.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
reverse-words.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
scratch.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
second-largest-item-in-bst.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
shuffle.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
stack.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
stacking-boxes.py Solve box-stacking problem 2020-11-13 16:57:47 +00:00
stock-price.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
todo.org Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
top-scores.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
topo-sort.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
traversals.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
utils.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00
word-cloud.py Add coding exercises for Facebook interviews 2020-11-12 14:37:29 +00:00