Total problems: 151
Check items as you complete them. Each link opens that problem’s
problem.mdinside this repo.
- Contains Duplicate
- Valid Anagram
- Two Sum
- Group Anagrams
- Top K Frequent Elements
- Product of Array Except Self
- Valid Sudoku
- Encode And Decode Strings
- Longest Consecutive Sequence
Some Notes on This Section: Hash maps provide constant time element lookup; you can check that you have come across specific elements in constant time. If counting element frequency, use a hash map. If you're checking element existence, use a set (also hashed elements, so constant time lookup)
- Valid Palindrome
- Two Sum II Input Array Is Sorted
- 3Sum
- Container With Most Water
- Trapping Rain Water
Some Notes on This Section: Two pointer problems typically start with pointers on opposite edges of the iterable object. You typically initialize both of the pointers to the start of the iterable object when you're doing a sliding window problem.
With this in mind, it's always best to start by trying to define your subproblem as some vertical slice of the interable object, or by the edges defined by the pointers. The "Trapping Rain Water" problem really tested my problem solving ability. Only when I clearly defined a bucket as some elevation < both edges did the solution start to formulate.
- Best Time to Buy And Sell Stock
- Longest Substring Without Repeating Characters
- Longest Repeating Character Replacement
- Permutation In String
- Minimum Window Substring
- Sliding Window Maximum
- Valid Parentheses
- Min Stack
- Evaluate Reverse Polish Notation
- Generate Parentheses
- Daily Temperatures
- Car Fleet
- Largest Rectangle In Histogram
- Binary Search
- Search a 2D Matrix
- Koko Eating Bananas
- Search In Rotated Sorted Array
- Find Minimum In Rotated Sorted Array
- Time Based Key Value Store
- Median of Two Sorted Arrays
- Reverse Linked List
- Merge Two Sorted Lists
- Reorder List
- Remove Nth Node From End of List
- Copy List With Random Pointer
- Add Two Numbers
- Linked List Cycle
- Find The Duplicate Number
- LRU Cache
- Merge K Sorted Lists
- Reverse Nodes In K Group
- Invert Binary Tree
- Maximum Depth of Binary Tree
- Diameter of Binary Tree
- Balanced Binary Tree
- Same Tree
- Subtree of Another Tree
- Lowest Common Ancestor of a Binary Search Tree
- Binary Tree Level Order Traversal
- Binary Tree Right Side View
- Count Good Nodes In Binary Tree
- Validate Binary Search Tree
- Kth Smallest Element In a Bst
- Construct Binary Tree From Preorder And Inorder Traversal
- Binary Tree Maximum Path Sum
- Serialize And Deserialize Binary Tree
- Kth Largest Element In a Stream
- Last Stone Weight
- K Closest Points to Origin
- Kth Largest Element In An Array
- Task Scheduler
- Design Twitter
- Find Median From Data Stream
- Subsets
- Combination Sum
- Permutations
- Subsets II
- Combination Sum II
- Word Search
- Palindrome Partitioning
- Letter Combinations of a Phone Number
- N Queens
- Number of Islands
- Clone Graph
- Max Area of Island
- Pacific Atlantic Water Flow
- Surrounded Regions
- Rotting Oranges
- Walls And Gates
- Course Schedule
- Course Schedule II
- Redundant Connection
- Number of Connected Components In An Undirected Graph
- Graph Valid Tree
- Word Ladder
Some Notes on This Section: Always opt for DFS when you have a choice in traversal problems. You can use the recursion stack to order your traversal, as opposed to having to maintain some queue for BFS. If you're given a set of (bi)directional relations (edges) between objects, you can probably solve the problem efficiently using graph traversal.
the defaultdict type from the collections library is helpful when creating adjacency lists. Pass list type to the constructor to specify adjacency list.
- Reconstruct Itinerary
- Min Cost to Connect All Points
- Network Delay Time
- Swim In Rising Water
- Alien Dictionary
- Cheapest Flights Within K Stops
- Climbing Stairs
- Min Cost Climbing Stairs
- House Robber
- House Robber II
- Longest Palindromic Substring
- Palindromic Substrings
- Decode Ways
- Coin Change
- Maximum Product Subarray
- Word Break
- Longest Increasing Subsequence
- Partition Equal Subset Sum
- Unique Paths
- Longest Common Subsequence
- Best Time to Buy And Sell Stock With Cooldown
- Coin Change II
- Target Sum
- Interleaving String
- Longest Increasing Path In a Matrix
- Distinct Subsequences
- Edit Distance
- Burst Balloons
- Regular Expression Matching
- Maximum Subarray
- Jump Game
- Jump Game II
- Gas Station
- Hand of Straights
- Merge Triplets to Form Target Triplet
- Partition Labels
- Valid Parenthesis String