LeetCode Grind Solutions
Master LeetCode with 200+ curated problems and detailed solutions.
LeetCode Grind Solutions
Master LeetCode with 200+ carefully curated problems, detailed solutions, and step-by-step explanations designed to get you interview-ready.
What You'll Learn
- 200+ Curated Problems: Hand-picked problems from Easy to Hard
- Pattern Recognition: Master the 14 essential coding patterns
- Time & Space Analysis: Deep understanding of algorithm complexity
- Interview Strategies: Proven techniques for technical interviews
- Real Problem Solutions: Production-quality code with explanations
š Complete Course Table of Contents
> š Preview Content (Free): You're currently viewing the preview version with sample problems and solutions. Subscribe to unlock the full course with 200+ problems, detailed explanations, and exclusive content.
šÆ Part 1: Foundation (Beginner Level) - 50 Problems
1.1 Arrays & Strings Basics (20 Problems)
Preview (Free):
- ā Two Sum (LeetCode #1) - Complete solution with 2 approaches
- ā Valid Parentheses (LeetCode #20) - Stack implementation
- ā Roman to Integer (LeetCode #13) - Hash map approach
Full Content (Subscribers Only):
- š Longest Common Prefix (LeetCode #14)
- š Valid Anagram (LeetCode #242)
- š First Unique Character (LeetCode #387)
- š Valid Palindrome (LeetCode #125)
- š Remove Duplicates (LeetCode #26)
- š Plus One (LeetCode #66)
- š Move Zeroes (LeetCode #283)
- š Contains Duplicate (LeetCode #217)
- š Single Number (LeetCode #136)
- š Intersection of Two Arrays (LeetCode #349)
- š Intersection of Two Arrays II (LeetCode #350)
- š Third Maximum Number (LeetCode #414)
- š Find All Numbers Disappeared (LeetCode #448)
- š Assign Cookies (LeetCode #455)
- š Hamming Distance (LeetCode #461)
- š Number Complement (LeetCode #476)
- š Keyboard Row (LeetCode #500)
1.2 Basic Data Structures (15 Problems)
Preview (Free):
- ā Hash Tables: Collision resolution, load factors
- ā Time Complexity: O(n), O(n²) analysis
- ā Space Complexity: O(1), O(n) optimization
Full Content (Subscribers Only):
- š Two Sum II (LeetCode #167)
- š Valid Perfect Square (LeetCode #367)
- š Arranging Coins (LeetCode #441)
- š Find All Anagrams (LeetCode #438)
- š Ransom Note (LeetCode #383)
- š First Unique Character (LeetCode #387)
- š Find the Difference (LeetCode #389)
- š Longest Palindrome (LeetCode #409)
- š Fizz Buzz (LeetCode #412)
- š Third Maximum Number (LeetCode #414)
- š Add Strings (LeetCode #415)
- š Count Segments (LeetCode #434)
- š Number of Boomerangs (LeetCode #447)
- š Find All Numbers Disappeared (LeetCode #448)
- š Assign Cookies (LeetCode #455)
- š Hamming Distance (LeetCode #461)
1.3 Simple Algorithms (15 Problems)
Preview (Free):
- ā Linear Search implementation
- ā Binary Search optimization
- ā Basic sorting algorithms
Full Content (Subscribers Only):
- š Binary Search (LeetCode #704)
- š Search Insert Position (LeetCode #35)
- š First Bad Version (LeetCode #278)
- š Sqrt(x) (LeetCode #69)
- š Guess Number Higher or Lower (LeetCode #374)
- š Search in Rotated Sorted Array (LeetCode #33)
- š Find Minimum in Rotated Sorted Array (LeetCode #153)
- š Search in Rotated Sorted Array II (LeetCode #81)
- š Find Peak Element (LeetCode #162)
- š Find Right Interval (LeetCode #436)
- š Path Sum III (LeetCode #437)
- š Find All Anagrams (LeetCode #438)
- š Number of Segments (LeetCode #434)
- š Add Strings (LeetCode #415)
- š Count Segments (LeetCode #434)
š Part 2: Intermediate Level - 75 Problems
2.1 Dynamic Programming (25 Problems)
Preview (Free):
- ā Climbing Stairs (LeetCode #70) - Fibonacci pattern
- ā House Robber (LeetCode #198) - Optimization problem
- ā Fibonacci Number (LeetCode #509) - Classic DP
Full Content (Subscribers Only):
- š Min Cost Climbing Stairs (LeetCode #746)
- š Longest Increasing Subsequence (LeetCode #300)
- š Coin Change (LeetCode #322)
- š Word Break (LeetCode #139)
- š Unique Paths (LeetCode #62)
- š Maximum Subarray (LeetCode #53)
- š Edit Distance (LeetCode #72)
- š Longest Common Subsequence (LeetCode #1143)
- š Burst Balloons (LeetCode #312)
- š Perfect Squares (LeetCode #279)
- š Word Break II (LeetCode #140)
- š Palindrome Partitioning (LeetCode #131)
- š Maximum Product Subarray (LeetCode #152)
- š House Robber II (LeetCode #213)
- š House Robber III (LeetCode #337)
- š Decode Ways (LeetCode #91)
- š Unique Binary Search Trees (LeetCode #96)
- š Interleaving String (LeetCode #97)
- š Distinct Subsequences (LeetCode #115)
- š Word Ladder (LeetCode #127)
- š Word Ladder II (LeetCode #126)
- š Surrounded Regions (LeetCode #130)
- š Clone Graph (LeetCode #133)
- š Gas Station (LeetCode #134)
- š Single Number II (LeetCode #137)
2.2 Graph Algorithms (25 Problems)
Preview (Free):
- ā Number of Islands (LeetCode #200) - DFS implementation
- ā Course Schedule (LeetCode #207) - Topological sort
- ā BFS and DFS traversal patterns
Full Content (Subscribers Only):
- š Course Schedule II (LeetCode #210)
- š Redundant Connection (LeetCode #684)
- š Network Delay Time (LeetCode #743)
- š Cheapest Flights Within K Stops (LeetCode #787)
- š Critical Connections (LeetCode #1192)
- š Alien Dictionary (LeetCode #269)
- š Word Ladder II (LeetCode #126)
- š Clone Graph (LeetCode #133)
- š Surrounded Regions (LeetCode #130)
- š Gas Station (LeetCode #134)
- š Single Number II (LeetCode #137)
- š Copy List with Random Pointer (LeetCode #138)
- š Word Break (LeetCode #139)
- š Word Break II (LeetCode #140)
- š Linked List Cycle (LeetCode #141)
- š Linked List Cycle II (LeetCode #142)
- š Reorder List (LeetCode #143)
- š Binary Tree Preorder Traversal (LeetCode #144)
- š Binary Tree Postorder Traversal (LeetCode #145)
- š LRU Cache (LeetCode #146)
- š Insertion Sort List (LeetCode #147)
- š Sort List (LeetCode #148)
- š Max Points on a Line (LeetCode #149)
- š Evaluate Reverse Polish Notation (LeetCode #150)
- š Reverse Words in a String (LeetCode #151)
2.3 Tree Traversal (25 Problems)
Preview (Free):
- ā Binary Tree Basics
- ā Inorder, Preorder, Postorder traversal
- ā Binary Search Tree validation
Full Content (Subscribers Only):
- š Maximum Depth of Binary Tree (LeetCode #104)
- š Same Tree (LeetCode #100)
- š Symmetric Tree (LeetCode #101)
- š Invert Binary Tree (LeetCode #226)
- š Binary Tree Level Order Traversal (LeetCode #102)
- š Construct Binary Tree from Preorder and Inorder (LeetCode #105)
- š Validate Binary Search Tree (LeetCode #98)
- š Serialize and Deserialize Binary Tree (LeetCode #297)
- š Binary Tree Maximum Path Sum (LeetCode #124)
- š Path Sum (LeetCode #112)
- š Path Sum II (LeetCode #113)
- š Path Sum III (LeetCode #437)
- š Lowest Common Ancestor (LeetCode #236)
- š Binary Tree Right Side View (LeetCode #199)
- š Count Complete Tree Nodes (LeetCode #222)
- š Invert Binary Tree (LeetCode #226)
- š Kth Smallest Element in BST (LeetCode #230)
- š Lowest Common Ancestor of BST (LeetCode #235)
- š Binary Tree Paths (LeetCode #257)
- š Add and Search Word (LeetCode #211)
- š House Robber III (LeetCode #337)
- š Sum of Left Leaves (LeetCode #404)
- š Find Mode in Binary Search Tree (LeetCode #501)
- š Find Bottom Left Tree Value (LeetCode #513)
- š Most Frequent Subtree Sum (LeetCode #508)
šÆ Part 3: Advanced Level - 50 Problems
3.1 Complex Algorithms (25 Problems)
Preview (Free):
- ā Advanced DP patterns
- ā Graph theory applications
- ā Backtracking techniques
Full Content (Subscribers Only):
- š Regular Expression Matching (LeetCode #10)
- š Wildcard Matching (LeetCode #44)
- š N-Queens (LeetCode #51)
- š N-Queens II (LeetCode #52)
- š Maximum Subarray (LeetCode #53)
- š Spiral Matrix (LeetCode #54)
- š Jump Game (LeetCode #55)
- š Merge Intervals (LeetCode #56)
- š Insert Interval (LeetCode #57)
- š Length of Last Word (LeetCode #58)
- š Spiral Matrix II (LeetCode #59)
- š Permutation Sequence (LeetCode #60)
- š Rotate List (LeetCode #61)
- š Unique Paths (LeetCode #62)
- š Unique Paths II (LeetCode #63)
- š Minimum Path Sum (LeetCode #64)
- š Valid Number (LeetCode #65)
- š Plus One (LeetCode #66)
- š Add Binary (LeetCode #67)
- š Text Justification (LeetCode #68)
- š Sqrt(x) (LeetCode #69)
- š Climbing Stairs (LeetCode #70)
- š Simplify Path (LeetCode #71)
- š Edit Distance (LeetCode #72)
- š Set Matrix Zeroes (LeetCode #73)
- š Search a 2D Matrix (LeetCode #74)
3.2 System Design Integration (25 Problems)
Preview (Free):
- ā Caching algorithms
- ā Load balancing concepts
- ā Distributed systems basics
Full Content (Subscribers Only):
- š Sort Colors (LeetCode #75)
- š Minimum Window Substring (LeetCode #76)
- š Combinations (LeetCode #77)
- š Subsets (LeetCode #78)
- š Word Search (LeetCode #79)
- š Remove Duplicates from Sorted Array II (LeetCode #80)
- š Search in Rotated Sorted Array II (LeetCode #81)
- š Remove Duplicates from Sorted List II (LeetCode #82)
- š Remove Duplicates from Sorted List (LeetCode #83)
- š Largest Rectangle in Histogram (LeetCode #84)
- š Maximal Rectangle (LeetCode #85)
- š Partition List (LeetCode #86)
- š Scramble String (LeetCode #87)
- š Merge Sorted Array (LeetCode #88)
- š Gray Code (LeetCode #89)
- š Subsets II (LeetCode #90)
- š Decode Ways (LeetCode #91)
- š Reverse Linked List II (LeetCode #92)
- š Restore IP Addresses (LeetCode #93)
- š Binary Tree Inorder Traversal (LeetCode #94)
- š Unique Binary Search Trees (LeetCode #96)
- š Interleaving String (LeetCode #97)
- š Validate Binary Search Tree (LeetCode #98)
- š Recover Binary Search Tree (LeetCode #99)
- š Same Tree (LeetCode #100)
šļø Part 4: Architect Level - 25 Problems
4.1 Large-Scale Problems (15 Problems)
Preview (Free):
- ā Distributed algorithms concepts
- ā Performance optimization techniques
- ā Scalability patterns
Full Content (Subscribers Only):
- š Symmetric Tree (LeetCode #101)
- š Binary Tree Level Order Traversal (LeetCode #102)
- š Binary Tree Zigzag Level Order Traversal (LeetCode #103)
- š Maximum Depth of Binary Tree (LeetCode #104)
- š Construct Binary Tree from Preorder and Inorder (LeetCode #105)
- š Construct Binary Tree from Inorder and Postorder (LeetCode #106)
- š Binary Tree Level Order Traversal II (LeetCode #107)
- š Convert Sorted Array to Binary Search Tree (LeetCode #108)
- š Convert Sorted List to Binary Search Tree (LeetCode #109)
- š Balanced Binary Tree (LeetCode #110)
- š Minimum Depth of Binary Tree (LeetCode #111)
- š Path Sum (LeetCode #112)
- š Path Sum II (LeetCode #113)
- š Flatten Binary Tree to Linked List (LeetCode #114)
- š Distinct Subsequences (LeetCode #115)
4.2 Real-World Applications (10 Problems)
Preview (Free):
- ā Database design patterns
- ā Microservices architecture
- ā Cloud computing concepts
Full Content (Subscribers Only):
- š Populating Next Right Pointers (LeetCode #116)
- š Populating Next Right Pointers II (LeetCode #117)
- š Pascal's Triangle (LeetCode #118)
- š Pascal's Triangle II (LeetCode #119)
- š Triangle (LeetCode #120)
- š Best Time to Buy and Sell Stock (LeetCode #121)
- š Best Time to Buy and Sell Stock II (LeetCode #122)
- š Best Time to Buy and Sell Stock III (LeetCode #123)
- š Binary Tree Maximum Path Sum (LeetCode #124)
- š Valid Palindrome (LeetCode #125)
šÆ Company-Specific Problem Sets
Google Interview Prep (25 Problems)
Preview (Free):
- ā Two Sum, 3Sum, Valid Parentheses
- ā Number of Islands, Course Schedule
- ā Word Ladder, Alien Dictionary
Full Content (Subscribers Only):
- š Word Ladder II (LeetCode #126)
- š Clone Graph (LeetCode #133)
- š Gas Station (LeetCode #134)
- š Single Number II (LeetCode #137)
- š Copy List with Random Pointer (LeetCode #138)
- š Word Break (LeetCode #139)
- š Word Break II (LeetCode #140)
- š Linked List Cycle (LeetCode #141)
- š Linked List Cycle II (LeetCode #142)
- š Reorder List (LeetCode #143)
- š Binary Tree Preorder Traversal (LeetCode #144)
- š Binary Tree Postorder Traversal (LeetCode #145)
- š LRU Cache (LeetCode #146)
- š Insertion Sort List (LeetCode #147)
- š Sort List (LeetCode #148)
- š Max Points on a Line (LeetCode #149)
- š Evaluate Reverse Polish Notation (LeetCode #150)
- š Reverse Words in a String (LeetCode #151)
- š Maximum Product Subarray (LeetCode #152)
- š Find Minimum in Rotated Sorted Array (LeetCode #153)
- š Find Peak Element (LeetCode #162)
- š Missing Ranges (LeetCode #163)
- š Compare Version Numbers (LeetCode #165)
- š Fraction to Recurring Decimal (LeetCode #166)
Facebook/Meta Interview Prep (25 Problems)
Preview (Free):
- ā Valid Parentheses, Roman to Integer
- ā Group Anagrams, Product of Array Except Self
- ā Binary Tree Level Order Traversal
Full Content (Subscribers Only):
- š Excel Sheet Column Title (LeetCode #168)
- š Majority Element (LeetCode #169)
- š Two Sum III (LeetCode #170)
- š Excel Sheet Column Number (LeetCode #171)
- š Factorial Trailing Zeroes (LeetCode #172)
- š Binary Search Tree Iterator (LeetCode #173)
- š Dungeon Game (LeetCode #174)
- š Combine Two Tables (LeetCode #175)
- š Second Highest Salary (LeetCode #176)
- š Nth Highest Salary (LeetCode #177)
- š Rank Scores (LeetCode #178)
- š Largest Number (LeetCode #179)
- š Consecutive Numbers (LeetCode #180)
- š Employees Earning More Than Their Managers (LeetCode #181)
- š Duplicate Emails (LeetCode #182)
- š Customers Who Never Order (LeetCode #183)
- š Department Highest Salary (LeetCode #184)
- š Department Top Three Salaries (LeetCode #185)
- š Reverse Words in a String II (LeetCode #186)
- š Repeated DNA Sequences (LeetCode #187)
- š Best Time to Buy and Sell Stock IV (LeetCode #188)
- š Rotate Array (LeetCode #189)
- š Reverse Bits (LeetCode #190)
- š Number of 1 Bits (LeetCode #191)
- š Word Frequency (LeetCode #192)
Amazon Interview Prep (25 Problems)
Preview (Free):
- ā Two Sum, Valid Parentheses
- ā Longest Substring Without Repeating Characters
- ā Course Schedule, Word Ladder
Full Content (Subscribers Only):
- š Valid Phone Numbers (LeetCode #193)
- š Transpose File (LeetCode #194)
- š Tenth Line (LeetCode #195)
- š Delete Duplicate Emails (LeetCode #196)
- š Rising Temperature (LeetCode #197)
- š House Robber (LeetCode #198)
- š Binary Tree Right Side View (LeetCode #199)
- š Number of Islands (LeetCode #200)
- š Bitwise AND of Numbers Range (LeetCode #201)
- š Happy Number (LeetCode #202)
- š Remove Linked List Elements (LeetCode #203)
- š Count Primes (LeetCode #204)
- š Isomorphic Strings (LeetCode #205)
- š Reverse Linked List (LeetCode #206)
- š Course Schedule (LeetCode #207)
- š Implement Trie (LeetCode #208)
- š Minimum Size Subarray Sum (LeetCode #209)
- š Course Schedule II (LeetCode #210)
- š Add and Search Word (LeetCode #211)
- š Word Search II (LeetCode #212)
- š House Robber II (LeetCode #213)
- š Shortest Palindrome (LeetCode #214)
- š Kth Largest Element in an Array (LeetCode #215)
- š Combination Sum III (LeetCode #216)
šÆ Interview Preparation Strategy
Week 1-2: Foundation (Free Preview)
- ā Master basic data structures
- ā Solve 20 Easy problems from preview
- ā Focus on pattern recognition
- ā Understand time/space complexity
Week 3-4: Intermediate (Subscribers Only)
- š Tackle 50 Medium problems
- š Practice time complexity analysis
- š Mock interviews with detailed feedback
- š Company-specific problem sets
Week 5-6: Advanced (Subscribers Only)
- š 25 Hard problems and system design
- š Behavioral interview prep
- š Final mock interviews
- š Resume optimization tips
šÆ What Subscribers Get
š Free Preview Includes:
- ā 7 complete problem solutions with detailed explanations
- ā Basic pattern recognition techniques
- ā Time/space complexity analysis
- ā Interview tips and strategies
š Full Subscription Unlocks:
- š 200+ Complete Problem Solutions with step-by-step explanations
- š Company-Specific Problem Sets (Google, Facebook, Amazon, Microsoft, Apple)
- š Advanced Pattern Recognition with 14 essential coding patterns
- š Mock Interview Sessions with detailed feedback
- š Behavioral Interview Prep with STAR method framework
- š System Design Integration for senior-level positions
- š Resume Optimization and portfolio building tips
- š Exclusive Discord Community access
- š Priority Support and Q&A sessions
- š Certificate of Completion for LinkedIn
š° Pricing & Subscription
Free Preview: Access to 7 problems and basic content
Pro Subscription: $5/month (Founding Cohort Pricing)
Full Access: All 200+ problems, company sets, and exclusive content
> šÆ Ready to unlock your full potential? Subscribe now and join thousands of developers who've landed their dream jobs!
Detailed Problem Solutions
Problem 1: Two Sum (LeetCode #1) - EASY
Problem Statement:
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
Example:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
Solution 1: Brute Force (O(n²))
def twoSum(nums, target):
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
if nums[i] + nums[j] == target:
return [i, j]
return []
Time Complexity: O(n²)
Space Complexity: O(1)
Solution 2: Hash Map (O(n))
def twoSum(nums, target):
hashmap = {}
for i, num in enumerate(nums):
complement = target - num
if complement in hashmap:
return [hashmap[complement], i]
hashmap[num] = i
return []
Time Complexity: O(n)
Space Complexity: O(n)
Interview Tips:
- Always mention both approaches
- Explain trade-offs between time and space
- Follow-up: What if array is sorted? (Two Pointers)
Problem 2: Valid Parentheses (LeetCode #20) - EASY
Problem Statement:
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
Example:
Input: s = "()[]{}"
Output: true
Solution:
def isValid(s):
stack = []
mapping = {")": "(", "}": "{", "]": "["}
for char in s:
if char in mapping:
if not stack or stack.pop() != mapping[char]:
return False
else:
stack.append(char)
return not stack
Time Complexity: O(n)
Space Complexity: O(n)
Problem 3: Container With Most Water (LeetCode #11) - MEDIUM
Problem Statement:
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, 0) and (i, ai). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
Example:
Input: height = [1,8,6,2,5,4,8,3,7]
Output: 49
Solution:
def maxArea(height):
left, right = 0, len(height) - 1
max_area = 0
while left < right:
width = right - left
current_area = min(height[left], height[right]) * width
max_area = max(max_area, current_area)
if height[left] < height[right]:
left += 1
else:
right -= 1
return max_area
Time Complexity: O(n)
Space Complexity: O(1)
Problem 4: Longest Substring Without Repeating Characters (LeetCode #3) - MEDIUM
Problem Statement:
Given a string s, find the length of the longest substring without repeating characters.
Example:
Input: s = "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
Solution:
def lengthOfLongestSubstring(s):
char_set = set()
left = 0
max_length = 0
for right in range(len(s)):
while s[right] in char_set:
char_set.remove(s[left])
left += 1
char_set.add(s[right])
max_length = max(max_length, right - left + 1)
return max_length
Time Complexity: O(n)
Space Complexity: O(min(m,n))
Problem 5: Climbing Stairs (LeetCode #70) - EASY
Problem Statement:
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Example:
Input: n = 3
Output: 3
Explanation: There are three ways to climb to the top.
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step
Solution:
def climbStairs(n):
if n <= 2:
return n
prev2, prev1 = 1, 2
for i in range(3, n + 1):
current = prev1 + prev2
prev2 = prev1
prev1 = current
return prev1
Time Complexity: O(n)
Space Complexity: O(1)
Problem 6: Number of Islands (LeetCode #200) - MEDIUM
Problem Statement:
Given an m x n 2D binary grid which represents a map of '1's (land) and '0's (water), return the number of islands.
Example:
Input: grid = [
["1","1","1","1","0"],
["1","1","0","1","0"],
["1","1","0","0","0"],
["0","0","0","0","0"]
]
Output: 1
Solution:
def numIslands(grid):
if not grid:
return 0
def dfs(i, j):
if (i < 0 or i >= len(grid) or
j < 0 or j >= len(grid[0]) or
grid[i][j] != '1'):
return
grid[i][j] = '0' # Mark as visited
dfs(i + 1, j)
dfs(i - 1, j)
dfs(i, j + 1)
dfs(i, j - 1)
islands = 0
for i in range(len(grid)):
for j in range(len(grid[0])):
if grid[i][j] == '1':
dfs(i, j)
islands += 1
return islands
Time Complexity: O(m Ć n)
Space Complexity: O(m Ć n)
Problem 7: Course Schedule (LeetCode #207) - MEDIUM
Problem Statement:
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.
Example:
Input: numCourses = 2, prerequisites = [[1,0]]
Output: true
Explanation: There are a total of 2 courses to take. To take course 1 you should have finished course 0. So it is possible.
Solution:
def canFinish(numCourses, prerequisites):
# Build adjacency list
graph = [[] for _ in range(numCourses)]
in_degree = [0] * numCourses
for course, prereq in prerequisites:
graph[prereq].append(course)
in_degree[course] += 1
# Topological sort using BFS
queue = []
for i in range(numCourses):
if in_degree[i] == 0:
queue.append(i)
completed = 0
while queue:
course = queue.pop(0)
completed += 1
for next_course in graph[course]:
in_degree[next_course] -= 1
if in_degree[next_course] == 0:
queue.append(next_course)
return completed == numCourses
Time Complexity: O(V + E)
Space Complexity: O(V + E)
Course Structure
1. Arrays & Strings (50 problems)
Easy (20 problems):
- Two Sum, Valid Parentheses, Roman to Integer
- Longest Common Prefix, Valid Anagram
- First Unique Character, Valid Palindrome
Medium (25 problems):
- 3Sum, Container With Most Water
- Longest Substring Without Repeating Characters
- Group Anagrams, Product of Array Except Self
Hard (5 problems):
- Trapping Rain Water, Median of Two Sorted Arrays
- Regular Expression Matching
2. Dynamic Programming (40 problems)
Easy (15 problems):
- Climbing Stairs, House Robber
- Fibonacci Number, Min Cost Climbing Stairs
Medium (20 problems):
- Longest Increasing Subsequence
- Coin Change, Word Break
- Unique Paths, Maximum Subarray
Hard (5 problems):
- Edit Distance, Longest Common Subsequence
- Burst Balloons
3. Graphs (35 problems)
Easy (10 problems):
- Number of Islands, Course Schedule
- Find the Town Judge
Medium (20 problems):
- Course Schedule II, Redundant Connection
- Network Delay Time, Cheapest Flights Within K Stops
Hard (5 problems):
- Critical Connections, Alien Dictionary
- Word Ladder II
4. Trees (30 problems)
Easy (15 problems):
- Maximum Depth of Binary Tree
- Same Tree, Symmetric Tree
- Invert Binary Tree
Medium (12 problems):
- Binary Tree Level Order Traversal
- Construct Binary Tree from Preorder and Inorder
- Validate Binary Search Tree
Hard (3 problems):
- Serialize and Deserialize Binary Tree
- Binary Tree Maximum Path Sum
5. Backtracking (25 problems)
Medium (20 problems):
- Generate Parentheses, N-Queens
- Letter Combinations of a Phone Number
- Combination Sum, Permutations
Hard (5 problems):
- Word Search II, Sudoku Solver
- Palindrome Partitioning
6. Sliding Window (20 problems)
Easy (5 problems):
- Maximum Average Subarray I
- Longest Continuous Increasing Subsequence
Medium (15 problems):
- Longest Substring Without Repeating Characters
- Minimum Window Substring
- Sliding Window Maximum
Problem Categories by Company
Google (25 problems)
- Two Sum, 3Sum, Valid Parentheses
- Number of Islands, Course Schedule
- Word Ladder, Alien Dictionary
Facebook/Meta (25 problems)
- Valid Parentheses, Roman to Integer
- Group Anagrams, Product of Array Except Self
- Binary Tree Level Order Traversal
Amazon (25 problems)
- Two Sum, Valid Parentheses
- Longest Substring Without Repeating Characters
- Course Schedule, Word Ladder
Microsoft (25 problems)
- Two Sum, Valid Parentheses
- Roman to Integer, Longest Common Prefix
- Binary Tree Maximum Path Sum
Apple (20 problems)
- Two Sum, Valid Parentheses
- Roman to Integer, Longest Common Prefix
- Binary Tree Inorder Traversal
Interview Preparation Strategy
Week 1-2: Foundation
- Master basic data structures
- Solve 50 Easy problems
- Focus on pattern recognition
Week 3-4: Intermediate
- Tackle Medium problems
- Practice time complexity analysis
- Mock interviews
Week 5-6: Advanced
- Hard problems and system design
- Behavioral interview prep
- Final mock interviews
Common Interview Patterns
1. Two Pointers
- Two Sum (sorted array)
- Container With Most Water
- 3Sum, 4Sum
2. Sliding Window
- Longest Substring Without Repeating Characters
- Minimum Window Substring
- Maximum Average Subarray
3. Hash Map
- Two Sum, Group Anagrams
- First Unique Character
- Longest Consecutive Sequence
4. Dynamic Programming
- Climbing Stairs, House Robber
- Longest Increasing Subsequence
- Coin Change
5. Graph Traversal
- Number of Islands
- Course Schedule
- Word Ladder
Time Complexity Cheat Sheet
Algorithm | Time | Space | Use Case |
----------- | ------ | ------- | ---------- |
Two Pointers | O(n) | O(1) | Sorted arrays |
---|---|---|---|
Sliding Window | O(n) | O(1) | Subarray problems |
Hash Map | O(n) | O(n) | Lookup problems |
Binary Search | O(log n) | O(1) | Sorted arrays |
DFS/BFS | O(V + E) | O(V) | Graph traversal |
DP | O(n²) | O(n) | Optimization |
What's Next
After completing this course, you'll be ready to tackle any coding interview with confidence. You'll understand not just how to solve problems, but why certain approaches work better than others, and how to optimize your solutions for real-world performance.
LeetCode Grind Solutions
Master LeetCode with 200+ curated problems and detailed solutions.