| title | location | images | tags | privacy | createdAt | updatedAt | ||
|---|---|---|---|---|---|---|---|---|
Untitled Post |
19.2283, 72.9481 |
|
public |
2025-12-30 14:59:59 UTC |
2025-12-30 15:00:24 UTC |
TWO SUM CORE CONCEPT │ ├── Mathematical Reality: A + B = Target => B = Target - A │ ├── Decision: How to find B? │ │ │ ├── I don't want extra memory? ──▶ Brute Force (O(n²)) │ │ │ ├── Is the array already sorted? ──▶ Two Pointers (O(n)) │ │ │ ├── Can I use memory to be super fast? ──▶ Hash Map (O(n)) │ │ │ │ │ └── Two-Pass: Put all in Map, then Search. │ │ └── One-Pass (BEST): Search in Map, then Put. │ │ │ └── Do I need the original index? │ ├── NO ──▶ Sort it and use Two Pointers. │ └── YES ──▶ Use Hash Map (Value -> Index mapping).