93d7b5d8ea
Valid Anagram This one is a classic: `sorted(a) == sorted(b)` Group Anagrams Using product of prime numbers to create a key for anagrams is much faster than sorting the characters in each word. It is also satisfyingly simple. Encode and Decode Strings My initial implementation was clumsy and prone to fail for edge-cases. A more elegant solution is using something like: ```python def encode(words): return "".join("{}:{}".format(len(x), x) for x in words) ```
6.7 KiB
6.7 KiB
- Array
- Binary
- Dynamic Programming
- Graph
- Interval
- Linked List
- Matrix
- String
- Tree
- Maximum Depth of Binary Tree
- Same Tree
- Invert/Flip Binary Tree
- Binary Tree Maximum Path Sum
- Binary Tree Level Order Traversal
- Serialize and Deserialize Binary Tree
- Subtree of Another Tree
- Construct Binary Tree from Preorder and Inorder Traversal
- Validate Binary Search Tree
- Kth Smallest Element in a BST
- Lowest Common Ancestor of BST
- Implement Trie (Prefix Tree)
- Add and Search Word
- Word Search II
- Heap