Skip to content

Summary

Two Pointers

  • 167. Two Sum
  • 88. Merge Sorted Array
  • 21. Merge Two Sorted Lists
  • 86. Partition List
  • 23. Merging k Sorted Lists (heapq)
  • 19. The k-th Element from the End of a Linked List
  • 876. Middle of the Linked List
  • 141. Detect Cycle in a Linked List
  • 160. Intersection of Two Linked Lists

Sliding window

  • 76. Minimum Window Substring
  • 567. Permutation in String

Depth-First Search (DFS)

For queue, mark things as visited when we add them into the queue!!!

  • 695. Max Area of Island
  • 547. Number of Provinces
  • 417. Pacific Atlantic Water Flow

Backtrack

  • 46. Permutations
  • 77. Combinations
  • 79. Word Search
  • 51. N-Queens

Breadth-First Search (BFS)

BFS is good for shortest path problems NOTE:

1) Visited nodes need to be marked when entering 2) set is faster than list for "in" operation

  • 1091. Shortest Path in Binary Matrix (depth added to queue)
  • 934. Shortest Bridge
  • 127. Word Ladder

Dynamic Programming (DP)

NOTE:

1) n+1 initialization is really helpful

  • 70. Climbing Stairs
  • 198. House Robber
  • 413. Arithmetic Slices

Greedy Algorithm

  • 455. Assign Cookies
  • 135. Candy

1.1 Basic Knowledge Data Structure

1.2 Basic Knowledge Sort

2.1 Linked List Linked List

2.2 Array Array

2.3 Binary Tree Binary Tree