You don’t need red–black trees to get a front-end offer. Most interviews test whether you can handle everyday data problems you hit while building UIs: shape arrays, count things, manage history, reason about async, and keep it efficient enough.
Treat this as a minimum toolkit. Know these patterns well, and you’ll be ready for 90% of coding rounds without grinding endless puzzles.
What to actually know
| Topic | You should be able to… | Real FE tie-in |
|---|---|---|
| Arrays & Strings | map/filter/reduce; slice/splice; join/split; substrings | Format API data, paginate lists, search in text inputs |
| Maps & Sets | O(1) lookups; counts; dedupe | Count clicks; group items; unique tags/ids |
| Stacks & Queues | push/pop; enqueue/dequeue; two-stack tricks | Undo/redo; back/forward; task scheduling |
| Trees (light) | Traverse (DFS/BFS); flatten nested data | Render menus, comments, folders |
| Recursion basics | Turn recursive to iterative when needed | Nested components; deep search |
| Sorting & searching | Use built-ins; compare O(n log n) vs O(n²) | Sort tables; binary search on pre-sorted data |
| Big-O intuition | Estimate costs; avoid nested N² when possible | Keep lists snappy; choose the right data structure |
Patterns you’ll reuse
1) Frequency map (count things fast)
function counts(str: string): Record<string, number> {
const m: Record<string, number> = {};
for (const ch of str) m[ch] = (m[ch] || 0) + 1;
return m;
}
// e.g. highlight most common search terms2) Dedupe with Set (no nested loops)
const uniqueIds = Array.from(new Set([3,3,2,1,2])); // => [3,2,1]3) Group items (like a pivot)
function groupBy<T>(arr: T[], keyFn: (x: T) => string): Record<string, T[]> {
const out: Record<string, T[]> = {};
for (const item of arr) {
const k = keyFn(item);
(out[k] ||= []).push(item);
}
return out;
}4) Stack for undo/redo
class History<T> {
private past: T[] = []; private future: T[] = []; private curr: T | null = null;
set(v: T) { if (this.curr !== null) this.past.push(this.curr); this.curr = v; this.future = []; }
undo() { if (this.past.length) { this.future.push(this.curr as T); this.curr = this.past.pop()!; } }
redo() { if (this.future.length) { this.past.push(this.curr as T); this.curr = this.future.pop()!; } }
get() { return this.curr; }
}5) BFS/DFS (tree or graph-ish data)
type Node = { id: string; children?: Node[] };
function dfs(root: Node, visit: (n: Node) => void) {
const stack: Node[] = [root];
while (stack.length) {
const n = stack.pop()!;
visit(n);
for (const c of (n.children || []).slice().reverse()) stack.push(c);
}
}Complexity: just enough to choose well
| Structure / op | Lookup | Insert | Delete | Notes |
|---|---|---|---|---|
| Array (index) | O(1) | O(1) push | O(1) pop | Splice can be O(n) |
| Array (search) | O(n) | — | — | Use Map/Set for frequent lookups |
| Map / Set | O(1) avg | O(1) avg | O(1) avg | Great for counts/dedupe |
| Queue (array) | — | push O(1) | shift O(n) | Use ring buffer or two stacks if heavy |
| Stack | — | push O(1) | pop O(1) | Undo/redo, parsing |
Tie it back to the browser
- GroupBy + Map: aggregate analytics by route, user, or event type.
- Set: unique selected ids in multi-select UIs.
- Stack/Queue: history panes, toasts, task runners.
- DFS: render nested comments or sitemap trees.
- Big-O instinct: avoid N² filters on large lists; preindex with a Map.
Practice drills (10–15 mins each)
- unique(arr): return array without duplicates (Set).
- countBy(arr, fn): return frequency map by key (Map/Record).
- topK(arr, k): pick top k items by score (sort or heap-lite via partial sort).
- flatten(nested): recursively flatten arrays of arrays.
- undo/redo: implement with two stacks.
- binarySearch(sorted, x): quick index of an item (or insertion point).
👉 Do these in the coding practice area under a timer to simulate interview pace.
What you can safely skip (for FE interviews)
- Advanced trees (AVL, red–black), heavy graph algorithms, max-flow, segment/fenwick trees.
- Dynamic programming beyond simple memoization patterns.
- Exotic data structures you’ve never used in real UI work.
If a company truly needs those, they’ll say so up front. Most FE loops won’t. Spend your time where it pays off: data shaping, async control, and practical UI logic.
Mini study plan (1 week)
| Day | Focus | Target |
|---|---|---|
| Mon | Arrays & Strings | 3 drills (map/filter/reduce; substring; chunk) |
| Tue | Maps & Sets | counts, groupBy, unique |
| Wed | Stacks & Queues | undo/redo; queue with two stacks |
| Thu | Trees & Recursion | DFS render; flatten nested arrays |
| Fri | Sorting/Search + Big-O | binary search; spot N² vs N log N |
| Sat | Mock coding | 1 × 45m timed session; narrate; retro |
| Sun | Review | Re-do weak drills; write a 5-line summary of each topic |
Wrap-up
Keep it simple and useful. If you can shape data clearly, pick the right structure quickly, and explain your trade-offs, you’re already ahead of the pack. The rest is practice.
Next: jump into the coding practice area and run the drills above under a timer. Build the habit of shipping first, then improving.