- Practice problems.
- https://leetcode.com/problems/set-matrix-zeroes/. Solved. To be even more memory efficient, you can set the matrix values in-place to a known flag (None or something) rather than keep track or row and col sets to zero in the next iteration.
- https://leetcode.com/problems/sort-colors/. Easy to solve, not so easy to do in constant memory.
- https://leetcode.com/problems/minimum-window-substring/. A bit harder. Can iterate and store in dict, removing letters as necessary, like I did, or you can use 2 pointers. Right for expansion until you get all of T, then left for contraction to try to minimize it. Continue until it’s not a valid substring, then move left forward one and repeat.
- https://leetcode.com/problems/decode-ways/. Cool problem. Simply recurse on the different options, one or two digits. Always remember to memoize. In this case, the DP cuts the time in half. I scored faster that 95% of submissions.
- https://leetcode.com/problems/binary-tree-inorder-traversal/. Traversing with recursion easy. To do iteratively, look at it like BFS/DFS. Manage a stack/queue and pop off appropriately according to inorder/preorder/postorder.
- https://leetcode.com/problems/validate-binary-search-tree/. When recursing and check left/right less/greater than, don’t compare to the node’s value. You have to propagate the parent’s bounds, just add a lower and upper param. Compare to that, not node.val.
- For leetcode specifically, I’ve now finished the top 50 questions and the top 50 interview questions. Will finish the top 100 liked questions next (almost done), then continue through 51-150 for the top interview questions.
- https://leetcode.com/problems/symmetric-tree. Level-order stuff is a bit easier with iteration than recursion, similar to BFS.
- https://leetcode.com/problems/binary-tree-level-order-traversal/. BFS, but the simplified version. Just an iterative while loop with a list of children, then collect the vals.
- https://leetcode.com/problems/maximum-depth-of-binary-tree/. Basic BFS, just count the layer for max depth. You can do this recursively in a one-liner with:
- def foo(root): return 1 + max(foo(root.left), foo(root.right)) if root else 0
- Markets closed today for MLK holiday.
- Dinner last night with the snyders (+baby) and everyone in culver.
- Confirmed no supercontest late-pick-reminder email on saturday, as designed.
- Python 3 type hint with default:
- def sqrt(number: int = 0) -> float:
- Orated the 4 behavioral questions in prep.
- Run, push, sauna, meditate.
- Emailed Netflix to keep them in sync with the others.
- Roasted 5lbs of peanuts (450F 15min). Made 2.5lbs regular peanut butter and 2.5lbs pumpkin peanut butter.
- Reread https://github.com/donnemartin/system-design-primer and did a ton more practice system design questions, including whiteboard. Boggle, twitter.