02.01 · Cheat sheet
DSA Patterns
Read the constraints, spot the pattern, pick the data structure.
What fits in 1 second
Java does about 10⁸ simple steps per second.
| n up to | Target |
|---|---|
| 10 | O(n!) |
| 20 | O(2ⁿ) |
| 500 | O(n³) |
| 5,000 | O(n²) |
| 10⁶ | O(n log n) |
| 10⁸ | O(n) |
Data structure costs
| Structure | Main operations |
|---|---|
| Array | get O(1), search O(n), insert in the middle O(n) |
| HashMap / HashSet | get, put O(1) on average |
| TreeMap / TreeSet | get, put, floor, ceiling O(log n) |
| Heap (PriorityQueue) | peek O(1), push and pop O(log n) |
| Stack / Queue | push, pop O(1) |
| Linked list | insert at a known node O(1), search O(n) |
solulu Pro
Continue this cheat sheet with Pro
Inside: 8 sections.
- What fits in 1 second
- Data structure costs
- Sorting
- Clue → pattern
- Binary search
- Sliding window
- +2 more
Lifetime ₹1,999 ₹999 · Launch offer
Item 5 of 12 · updated 2026-10-13