Skip to content
Bill Liao
Go back

130 Most Popular LeetCode Problems and Answers

Edit page

Array:

  1. Two Sum
  2. Container With Most Water
  3. Best Time to Buy and Sell Stock
  4. Product of Array Except Self

String:

  1. Longest Substring Without Repeating Characters
  2. Valid Parentheses
  3. Valid Palindrome
  4. Reverse Words in a String
  5. Longest Palindromic Substring

Linked List:

  1. Reverse Linked List
  2. Merge Two Sorted Lists
  3. Remove Nth Node From End of List
  4. Linked List Cycle
  5. Intersection of Two Linked Lists

Stack:

  1. Min Stack
  2. Evaluate Reverse Polish Notation
  3. Daily Temperatures
  4. Remove All Adjacent Duplicates in String

Queue:

  1. Design Circular Queue
  2. Implement Stack using Queues
  3. Moving Average from Data Stream
  4. Queue Reconstruction by Height
  5. Number of Recent Calls

Binary Tree:

  1. Maximum Depth of Binary Tree
  2. Validate Binary Search Tree
  3. Binary Tree Level Order Traversal
  4. Lowest Common Ancestor of a Binary Tree
  5. Symmetric Tree

Binary Search Tree (BST):

  1. Kth Smallest Element in a BST
  2. Convert Sorted Array to Binary Search Tree
  3. Validate Binary Search Tree
  4. Inorder Successor in BST
  5. Range Sum of BST

Graph:

  1. Number of Islands
  2. Course Schedule
  3. Word Search
  4. Clone Graph
  5. Pacific Atlantic Water Flow

Hashing:

  1. Group Anagrams
  2. Valid Sudoku
  3. Subarray Sum Equals K
  4. Longest Consecutive Sequence

Dynamic Programming:

  1. Climbing Stairs
  2. Longest Increasing Subsequence
  3. Maximum Subarray
  4. Coin Change
  5. Unique Paths

Greedy Algorithms:

  1. Jump Game
  2. Task Scheduler
  3. Minimum Number of Arrows to Burst Balloons
  4. Non-overlapping Intervals
  5. Gas Station

Backtracking:

  1. N-Queens
  2. Letter Combinations of a Phone Number
  3. Permutations
  4. Subsets
  5. Palindrome Partitioning

Divide and Conquer:

  1. Merge Sort
  2. Quick Sort
  3. Kth Largest Element in an Array
  4. Maximum Subarray
  5. Count of Smaller Numbers After Self

Two Pointers:

  1. Two Sum II — Input array is sorted
  2. Trapping Rain Water

Sliding Window:

  1. Minimum Window Substring
  2. Maximum Points You Can Obtain from Cards
  3. Fruit Into Baskets
  4. Longest Repeating Character Replacement

Bit Manipulation:

  1. Single Number
  2. Number of 1 Bits
  3. Missing Number
  4. Reverse Bits
  5. Power of Two

Sorting and Searching:

  1. Merge Intervals
  2. First Missing Positive
  3. Search in Rotated Sorted Array
  4. Find First and Last Position of Element in Sorted Array

Math:

  1. Palindrome Number
  2. Roman to Integer
  3. Integer to English Words
  4. Pow(x, n)
  5. Happy Number

Recursion:

  1. Generate Parentheses
  2. Combinations

Design and Implementation:

  1. LRU Cache
  2. Implement Trie (Prefix Tree)
  3. Design Circular Queue

Union Find (Disjoint Set):

  1. Friend Circles
  2. Accounts Merge
  3. Surrounded Regions
  4. Redundant Connection

Trie:

  1. Add and Search Word — Data structure design
  2. Word Search II
  3. Replace Words
  4. Implement Magic Dictionary

Heap (Priority Queue):

  1. Merge k Sorted Lists
  2. Top K Frequent Elements
  3. Find Median from Data Stream
  4. Ugly Number II

Topological Sort:

  1. Course Schedule
  2. Alien Dictionary
  3. Sequence Reconstruction
  4. Reconstruct Itinerary
  5. Course Schedule II

Breadth-First Search (BFS):

  1. Word Ladder
  2. Binary Tree Level Order Traversal
  3. Minimum Genetic Mutation

Depth-First Search (DFS):

  1. Binary Tree Paths
  2. Flatten Binary Tree to Linked List
  3. Word Break
  4. Remove Invalid Parentheses
  5. All Paths From Source to Target

Segment Tree:

  1. Range Sum Query — Mutable
  2. Count of Range Sum
  3. The Skyline Problem
  4. Range Minimum Query (RMQ)

Fenwick Tree (Binary Indexed Tree):

  1. Reverse Pairs
  2. Range Sum Query 2D — Mutable

Linked List Manipulation:

  1. Swap Nodes in Pairs

Tree Traversals:

  1. Binary Tree Preorder Traversal
  2. Binary Tree Inorder Traversal
  3. Binary Tree Postorder Traversal
  4. N-ary Tree Preorder Traversal
  5. N-ary Tree Postorder Traversal
  6. Lowest Common Ancestor of a Binary Search Tree

Geometry:

  1. Valid Square
  2. K Closest Points to Origin
  3. Number of Boomerangs
  4. Convex Hull
  5. Max Points on a Line

Edit page
Share this post:

Previous Post
Two Sum
Next Post
Uber System Design Interview Question and Answer