Nlogk
Cheat Sheet

Constraints To Tags

ConstraintTime ComplexityTags
n ≈ 10^8O(log n) / O(√n) / O(1)Binary Search, Math, GCD/LCM, Fast Power, Binary Representation, Prime Numbers
n ≈ 10^6O(n)Two Pointers, Stack/Queue, Hash Table/Set, Prefix Sum, Greedy, 1D-DP, BFS/DFS on Tree, Topological Sort, Union Find
n ≈ 10^5O(n log n)Sorting (Merge/Quick), Binary Search (Advanced), Heap/Priority Queue, Tree Map/Set, Segment Tree, Intervals
n ≈ 10^4O(n²)2D-DP, Matrix Operations, Graph Algorithms (BFS/DFS), Shortest Path (Bellman-Ford), Palindrome
n ≈ 200O(n³)3D-DP, Floyd Warshall, All Pairs Shortest Path, Three Pointers
n ≈ 20O(2^n) / O(n!)Backtracking, Bitmask DP, Subset Generation, Permutations, Combinations

Below is a visual representation of different algorithm complexities and their common use cases:

Algorithm Complexity Guide

n ≈ 10^8
O(log n) / O(√n) / O(1)
Binary Search
Math
GCD/LCM
Fast Power
Binary Representation
Prime Numbers
n ≈ 10^6
O(n)
Two Pointers
Stack/Queue
Hash Table/Set
Prefix Sum
Greedy
1D-DP
BFS/DFS on Tree
Topological Sort
Union Find
n ≈ 10^5
O(n log n)
Sorting (Merge/Quick)
Binary Search (Advanced)
Heap/Priority Queue
Tree Map/Set
Segment Tree
Intervals
n ≈ 10^4
O(n²)
2D-DP
Matrix Operations
Graph Algorithms (BFS/DFS)
Shortest Path (Bellman-Ford)
Palindrome
n ≈ 200
O(n³)
3D-DP
Floyd Warshall
All Pairs Shortest Path
Three Pointers
n ≈ 20
O(2^n) / O(n!)
Backtracking
Bitmask DP
Subset Generation
Permutations
Combinations