A comprehensive collection of algorithm problems and solutions designed as a structured learning resource. This repository contains problems from LeetCode, organized by patterns and difficulty to facilitate systematic learning.
- Pattern Reference - Common algorithm patterns with templates
- Interview Prep - Interview strategies and tips
This repository follows these principles:
- Pattern Recognition: Group problems by algorithmic patterns
- Multiple Solutions: Document brute force → optimized approaches
- Spaced Repetition: Review problems at intervals (1 week, 1 month, 3 months)
- Deep Understanding: Focus on why solutions work, not just how
Work through categories in this order: 🟢 Beginner → 🟡 Intermediate → 🔴 Advanced
Focus: Hash tables for O(1) lookups, frequency counting
- Contains Duplicate
- Duplicate Zeros
- Group Anagrams
- Longest Consecutive Sequence
- Max Consecutive Ones
- Product of Array Except Self
- Top K Frequent Elements
- Two Sum
- Valid Anagram
- Valid Sudoku
Focus: Left/right pointers, in-place modification
- Valid Palindrome
- Two Sum II Input Array Is Sorted
- 3Sum
- Container With Most Water
- Trapping Rain Water
- Palindrome Number
Focus: LIFO operations, matching pairs
- Valid Parentheses
- Min Stack
- Evaluate Reverse Polish Notation
- Generate Parentheses
- Daily Temperatures
- Car Fleet
- Largest Rectangle In Histogram
Focus: Dynamic window sizing, optimization
- Best Time to Buy and Sell Stock
- Longest Substring Without Repeating Characters
- Longest Repeating Character Replacement
- Minimum Window Substring
- Permutation In String
- Sliding Window Maximum
Focus: O(log n) search, boundary conditions
- Binary Search
- Find Minimum in Rotated Sorted Array
- Koko Eating Bananas
- Median of Two Sorted Arrays
- Search a 2D Matrix
- Search in Rotated Sorted Array
- Time Based Key Value Store
Focus: DFS/BFS, tree traversal
- Maximum Depth of Binary Tree
- Same Tree
- Invert 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 pre order and in order traversal
- Validate Binary Search Tree
- Kth Smallest Element in a BST
- Lowest Common Ancestor of BST
- Add and Search Word
- Diameter of Binary Tree
- Balanced Binary Tree
- Binary Tree Right Side View
- Count Good Nodes In Binary Tree
Focus: Decision trees, exploring all possibilities
- Subsets
- Combination Sum
- Permutations
- Subsets II
- Combination Sum II
- Palindrome Partitioning
- Letter Combinations of a Phone Number
- N Queens
Focus: Memoization, optimal substructure
- Climbing Stairs
- Combination Sum IV
- Coin Change
- Decode Ways
- House Robber
- House Robber II
- Jump Game
- Min Cost Climbing Stairs
- Palindromic Substrings
- Longest Palindromic Substring
- 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
Focus: Graph traversal, cycle detection
- Clone Graph
- Course Schedule
- Pacific Atlantic Water Flow
- Number of Islands
- Longest Consecutive Sequence
- Graph Valid Tree
- Number of Connected Components in an Undirected Graph
- Reconstruct Itinerary
- Min Cost to Connect All Points
- Network Delay Time
- Swim in Rising Water
- Alien Dictionary
- Cheapest Flights Within K Stops
Focus: Local optimal choices
- Maximum Subarray
- Jump Game
- Jump Game II
- Gas Station
- Hand of Straights
- Merge Triplets to Form Target Triplet
- Partition Labels
- Valid Parenthesis String
Focus: Min/max operations, top K elements
- Kth Largest Element in a Stream
- Last Stone Weight
- K Closest Points to Origin
- Kth Largest Element in an Array
- Task Scheduler
- Design Twitter
- Merge K Sorted Lists
- Find Median from Data Stream
Focus: Overlapping intervals, merging
- Insert Interval
- Merge Intervals
- Non-overlapping Intervals
- Meeting Rooms
- Meeting Rooms II
- Minimum Interval to Include Each Query
Focus: Pointer manipulation, cycle detection
- 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
Focus: Matrix operations, mathematical patterns
- Rotate Image
- Spiral Matrix
- Set Matrix Zeroes
- Happy Number
- Plus One
- Pow(x, n)
- Multiply Strings
- Detect Squares
Focus: Prefix matching, word search
Focus: FIFO operations, level-order processing