Skip to content

Latest commit

 

History

History
141 lines (60 loc) · 1.3 KB

File metadata and controls

141 lines (60 loc) · 1.3 KB

1D

Heap

Stack

  • Functions: peek(), pop(), push()

Queue

  • Functions: peek(), poll(), add()/offer()
  • Linked List

Tree

Tree

Depth-first Search

Breadth-first Search

Binary Search Tree

Binary Indexed Tree

Segment Tree

Union Find

Trie

Graph

Graph

Topological Sort

Array

Array

  • Arrays.asList([1,2,3]);

Two Pointers

Binary Search

Sort

Hash

Map

Hash Table

Basics

Math

  • 转换成string
  • % mod, 除法
  • Integer.MAX_VALUE, Integer.MIN_VALUE; if overflow, use long

String

  • s.toCharArray()
  • String.valueOf(charArrary)
  • sb = new StringBuffer()
  • sb.reverse(), sb.append(), sb.deleteCharAt(), sb.length()

Bit Manipulation

DP

Dynamic Programming

Optimization problems:

  • memoization && subproblems
  • Fibonacci
  • Shortest paths
  • guessing && DAG View

Backtracking

  • Finding all (or some) solutions to some computational problems, notebaly constraint satisfaction problems
  • It attemps to build/find all candidates and abandon partial candidate when the candidates appears not to be suitable(backtracking, backing off from wrong candidates)

Fancy

Memoization

Minimax

Reservoir Sampling

Geometry

Brainteaser

Approach

Greedy

Divide and Conquer

Recursion

Design