Data structures and Algorithms in TypeScript
Data Structures
Algorithms
Patterns
- Two Pointers
- Sliding Window
- Matrix Treversal
- Arrays
- LinkedList
- Tree BFS Treversal
- Tree DFS Treversal
- Binary Search
General Tips
- If input array is sorted then
- Two pointers
- Sliding window
- Binary search
- If given a tree then
- DFS
- BFS
- If given a linked list then
- Offset pointers
- Fast & slow pointers
- If recursion is banned then
- Stack
- If must solve in-place then
- Swap corresponding values
- Store one or more different values in the same pointer
- If asked for common strings then
- Map
- Trie
- Else
- Map/Set for O(1) time & O(n) space
- Sort input for O(nlogn) time and O(1) space