24. Named-question cheat sheet (DSA) + LP last

Adarsh Vishwakarma · SDE I AUTA APJ · Job 10454435 · ADCI Karnataka. Java on Zoom + Amazon Live Code. Production internships used Python, TypeScript, and ROS2; Live Code is still Java. R1 (13 Aug 2026) and R2 (18 Aug 2026) are done. OA is not a round. This book is for R3 and a possible R4 (Bar Raiser / HM / GenAI Fluency when scheduled). Job 10454435 still has none — no public IE names a live-round question for this Job ID. Unnamed stays unnamed. These are families other candidates reported — your loop may differ. This chapter is a scan cheat, not a reprint of chapter 05. Full Java novels stay in 05. Pattern-from-clue is chapter 25. OA is not a round — this file does not expand an OA table.

Labels: IE-asked first-hand named prompt (other loops). Standard CS conceptual or year-out remainder. OA problems are omitted. Intern cards are an appendix. SDE II / US 3×60 / FTC are NMF one-liners, not expanded. Maximum Sum Linked List is not LC 962. Delivery stations is not LC 210. Login Tracker is unverified. Rate Limiter SDE I count = 1, not UTA.

Grey box = the questionTable = dry run with numbersItalic = what to sayFull Java stays in chapter 05If the algo is unclear: DSA Notes

0. How to speak a cheat card in 60 seconds

1. Grey box
the actual question — restate this out loud first
2. Example
tiny numbers. If they draw a different tree, use theirs
3. Dry-run table
what the DS holds at each step — this is the understanding
4. Then brute / optimal / Java
full novels stay in chapter 05
5. If the algo is the gap
open DSA Notes — two examples, simple Java, interview Java

Every DSA card below is meant to be read in this order: question → example → dry-run table → why brute dies → optimal DS → tiny Java. If a card still feels thin, open the chapter 05 link and dry-run their example there. Unnamed cards stay unnamed: use the dry-run as a shape, not a guessed LeetCode.

  1. Clarify input, range, and what “good” means. If the title is similar-to, lock the difference.
  2. Say brute + time. They want to hear n² / 2ⁿ before the trick.
  3. Say why brute dies at their n, then the invariant and the Java DS (what one map entry stores).
  4. Code the inner loop. Dry-run their example. Time and space.
  5. If the invite said Fluency and they pasted a tree, write the tree first (Distance K).

Do not forecast Job 10454435. Do not stamp ids on unnamed prompts. Do not stamp LC 962 or LC 210 on Maximum Sum Linked List / LC 6369243. Login Tracker is unverified. Rate Limiter independent SDE I live count = 1, OA+3 system design, not UTA two-DSA. Do not speak chapter 13 as Adarsh. OA is not a round: if their write-up numbered OA as Round 1, their “R3” is often this loop’s already-done R2 analogue.

1. Later-slot / Fluency / chapter 05 families

Short form. Open the chapter 05 id for the full compilable Java.

All Nodes Distance K without parent map IE-asked

Question they ask. You are given a binary tree and a target node. Return every node value whose path distance from the target is exactly k. They may forbid storing a parent Map.

Example. Tree: root 1, left 2, right 3; 2 has left 4 and right 5. Target = node 5, k = 2. Paths of length 2 from 5: 5→2→1 and 5→2→4. Answer: [1, 4] (order does not matter). Use their drawing if they draw a different tree.

Dry run — walk this before you code.

StepWhat you holdResult / why
0Stand on target 5. Distance 0. Do not add it unless k=0.Need nodes at dist 2.
1Build undirected edges while DFS: parent is an argument, not a HashMap. 5 connected to 2.Now 5 can walk up.
2BFS from 5. Layer 1: 2.Not yet k.
3Layer 2: from 2 you reach 1 and 4 (2’s other child). Skip 5 (already visited).Collect 1 and 4. Stop.

Say out loud. I will not store Map<Node,Node>. Parent is a DFS argument. Then BFS from the target. Time O(n), space O(n).

Source. LC 7406809 AUTA R2; LC 7623949 Fluency-labeled slot was DSA. Full Java: distance-k-no-parent-map.

Clue → pattern. Tree + distance K + they forbid a parent Map → undirected view or recursive return.

Why this. Distance K from a target needs parent edges. Storing Map<Node,Node> is what they banned. Pass parent as a DFS argument while you build adj, then BFS from target. Or recurse: find returns distance to target; on the way up, collect the other subtree at k−dist−1.

Brute. Store parent map (forbidden) or enumerate all nodes and path-length via LCA O(n²). Time O(n²). Space O(n).

Optimal. Build undirected adj O(n), BFS O(n). No parent HashMap. Time O(n). Space O(n).

int dfs(TreeNode n, TreeNode t, int k, List<Integer> a) {
  if (n == null) return -1;
  if (n == t) { down(n, k, a); return 0; }
  int L = dfs(n.left, t, k, a);
  if (L >= 0) { if (L + 1 == k) a.add(n.val); down(n.right, k - L - 2, a); return L + 1; }
  int R = dfs(n.right, t, k, a);
  if (R >= 0) { if (R + 1 == k) a.add(n.val); down(n.left, k - R - 2, a); return R + 1; }
  return -1;
}

Fluency invite can still be this tree. Write the tree first. Intern LC 7643209 unnamed min-heap is not Distance K.

Next Greater Element IE-asked

Question they ask. For every index, find the first value to its right that is strictly greater. If none, -1. Confirm: one array vs two arrays; circular or not.

Example. Input [2, 1, 2, 4, 3] → output [4, 2, 4, -1, -1].

Dry run — walk this before you code.

StepWhat you holdResult / why
i=0, val=2Look right: 1 no, 2 no, 4 yes.ans[0]=4. Brute would scan. Stack remembers unresolved indices.
i=1, val=1Next is 2, which is greater.ans[1]=2.
i=2, val=2Next greater is 4.ans[2]=4.
i=3, val=43 is smaller; nothing after.ans[3]=-1. Stack pops when a later bigger value arrives.
i=4, val=3End of array.ans[4]=-1. Each index pushed/popped once → O(n).

Say out loud. Brute is nested j>i, O(n²). Optimal: decreasing ArrayDeque of indices. Next-greater-same digits is next permutation, not this.

Source. LC 7724048 mapped R3 HM. Full Java: next-greater-element.

Clue → pattern. Next greater / next warmer day → monotonic stack.

Why this. Each index waits for the first later larger value. A decreasing stack of unresolved indices pops when today is the answer. Nested scan is the brute they expect you to name.

Brute. For each i scan i+1..n−1. Time O(n²). Space O(1).

Optimal. ArrayDeque of indices, decreasing values. Time O(n). Space O(n).

int[] nge(int[] a) {
  int n = a.length; int[] ans = new int[n]; Arrays.fill(ans, -1);
  Deque<Integer> st = new ArrayDeque<>();
  for (int i = n - 1; i >= 0; i--) {
    while (!st.isEmpty() && st.peek() <= a[i]) st.pop();
    if (!st.isEmpty()) ans[i] = st.peek();
    st.push(a[i]);
  }
  return ans;
}

Next greater same digits is next permutation, not this stack.

Dynamic k-th largest (k changes) IE-asked

Question they ask. Maintain the k-th largest while numbers are added (and k may change). Not a static sort-once.

Example. Stream [4, 5, 8, 2], k=3. After these four, 3rd largest is 4. Then add 3; 3rd largest is still 4. If they set k=2, 2nd largest is 5.

Dry run — walk this before you code.

StepWhat you holdResult / why
add 4min-heap of size k=3: [4]Not full yet — if they still want kth, define the rule (null vs current).
add 5,8heap [4,5,8], peek=4Size 3. Peek is the kth largest.
add 22 < peek, ignore (or offer and poll if you always offer)Keep size 3: still [4,5,8], kth=4.
add 33 < 4, ignorekth still 4.
setK(2)Need 2nd largest = 5. Rebuild or keep a larger structure.Quickselect is for a frozen array, not a stream.

Say out loud. Size-k min-heap: peek is kth. If they delete arbitrary values, TreeMap counts, not a Java PriorityQueue.

Source. LC 7850431 mapped R3. Full Java: dynamic-kth-largest.

Clue → pattern. Kth while the stream / k moves → heap policy, not one sort.

Why this. Static kth is size-k min-heap. If k or the set changes, you need a structure that inserts/deletes. Size-k heap still works if you re-fill; two heaps if it is a running median-like policy.

Brute. Sort after every update. Time O(q n log n). Space O(n).

Optimal. Min-heap of size k, or TreeMap counts if they delete arbitrary values. Time O(log n) per update typical. Space O(n).

PriorityQueue min = new PriorityQueue<>(); // size k

Quickselect is for a static array, not a stream of updates.

Variation of Find All Anagrams IE-asked

Question they ask. Find every start index where a substring of s is an anagram of p (same letters, any order). Window length is |p|.

Example. s = cbaebabacd, p = abc → starts [0, 6] because cba and bac match.

Dry run — walk this before you code.

StepWhat you holdResult / why
needp=abc → counts a1 b1 c1Need that exact bag in every window of length 3.
win [0..2] cbac1 b1 a1 — matches needRecord 0.
slide to [1..3] baelose c, gain eMismatch.
… until [6..8] bacb,a,c match againRecord 6. One add/remove per step → O(n).

Say out loud. Do not sort every substring. Fixed window + int[26]. Group-anagrams of whole words is a different map-of-keys problem.

Source. LC 8362604 AUTA R3 HM. Full Java: find-anagrams-variation.

Clue → pattern. Same multiset in a window of length p → fixed window + counts.

Why this. Anagram = same frequencies. Window size is |p|. Slide one char; compare 26-counts. Not “exactly K distinct.”

Brute. Sort every substring of length m. Time O(n m log m). Space O(m).

Optimal. int[26] need vs have; match counter. Time O(n). Space O(1).

// add s[r]; remove s[r-m]; if match record r-m+1

Group anagrams (whole strings) is HashMap of sorted key — different card (Sachin LC 49).

Combine Garlands / connect ropes IE-asked

Question they ask. You repeatedly glue two ropes/garlands. Cost of a glue is the sum of those two lengths. The new rope goes back into the pile. Minimize total cost.

Example. [4, 3, 2, 6]. Always merge the two smallest.

Dry run — walk this before you code.

StepWhat you holdResult / why
startheap 2,3,4,6Do not sort once and stop — the merge re-enters.
merge 2+3=5cost += 5. heap 4,5,6Paid 5.
merge 4+5=9cost += 9. heap 6,9Paid 14 so far.
merge 6+9=15cost += 15. heap 15Total 29. Use long.

Say out loud. Why not sort once? After 2+3 the new 5 competes with 4. Heap, not Koko (Koko is binary search on speed).

Source. LC 8362604 AUTA; GFG 2025 Connect Sticks (OA-as-R1 on that GFG). Full Java: combine-garlands.

Clue → pattern. Repeatedly merge two pieces, cost = sum → min-heap.

Why this. After you merge, the new length goes back into the set. One sort is wrong because the merge order is data-dependent. Always take the two smallest.

Brute. Try all merge orders. Time exponential. Space O(n).

Optimal. PriorityQueue; poll+poll, add cost, offer sum. Use long. Time O(n log n). Space O(n).

while (pq.size() > 1) { long s = pq.poll() + pq.poll(); cost += s; pq.offer(s); }

Koko min-speed is BS on answer, not this heap.

Count Number of Nice Subarrays IE-asked

Question they ask. Count contiguous subarrays that contain exactly k odd numbers.

Example. [1,1,2,1,1], k=3 → 2 subarrays: [1,1,2,1] and [1,2,1,1].

Dry run — walk this before you code.

StepWhat you holdResult / why
exactly k is not monotoneAdding an element can add an odd and go from k to k+1Cannot only shrink for “exactly”.
atMost(k)Count windows with ≤ k odds. While odds > k, move left.Monotone budget.
atMost(3)−atMost(2)Windows with ≤3 odds minus windows with ≤2 oddsLeaves exactly 3. Answer 2 on the example.

Say out loud. Odds are 0/1. Exact-sum with negatives is prefix+HashMap, not this window.

Source. LC 6806195 AUTA BR. Full Java: nice-subarrays.

Clue → pattern. Exactly K odds in a subarray → atMost(K) − atMost(K−1).

Why this. Odds are a 0/1 budget. “Exactly K” is not monotone; “at most K” is. Subtract.

Brute. All L,R count odds. Time O(n²). Space O(1).

Optimal. Two sliding windows on odd count. Time O(n). Space O(1).

int atMost(int[] a, int k) {
  int l = 0, odds = 0, ans = 0;
  for (int r = 0; r < a.length; r++) {
    odds += a[r] & 1;
    while (odds > k) odds -= a[l++] & 1;
    ans += r - l + 1;
  }
  return ans;
}
int numberOfNice(int[] a, int k) { return atMost(a, k) - atMost(a, k - 1); }

Exact sum with negatives is prefix+map, not this window. Do not prefix-sum odds into a HashMap unless they want a different exact-sum wording — window is enough on 0/1.

Tree path A/B/C print IE-asked

Question they ask. UNNAMED print format. They named nodes A/B/C on a tree and wanted a path printed or marked. Ask what A, B, C are and what to print.

Example. Suppose A=2, B=5, C unused. Path 2-1-5. Do not invent their letters.

Dry run — walk this before you code.

StepWhat you holdResult / why
askPrint the path? Mark edges? LCA only?Unnamed stays unnamed.
find LCAPath A→LCA plus LCA→B (reverse one side)O(n) one or two DFS. Parent as argument if they ban a map.

Say out loud. Do not stamp LC 236 as the asked id. Confirm the print spec, then DFS.

Source. LC 7406809 AUTA BR. UNNAMED details — no LC id. Full Java: tree-path-abc.

Clue → pattern. Print / mark a path between named nodes on a tree.

Why this. Find LCA or recurse “does this subtree contain A/B/C.” Stay unnamed on the exact print format they used.

Brute. All pairs paths. Time O(n²). Space O(n).

Optimal. One or two DFS; parent-as-arg if they ban a map. Time O(n). Space O(n).

// do not invent the print spec; ask what A/B/C means

Unnamed stays unnamed. Do not stamp LC 236 as “what they asked.”

Top-K Frequent Elements IE-asked

Question they ask. Return the k values that appear most often. Order of the k answers: ask.

Example. [1,1,1,2,2,3], k=2 → [1,2].

Dry run — walk this before you code.

StepWhat you holdResult / why
count1→3, 2→2, 3→1HashMap first.
size-k min-heap on freqOffer (3,1), (2,2), (1,3). When size>k poll the smallest freqHeap holds 1 and 2. You did not sort all unique keys.

Say out loud. O(n log k) after counting. Bucket sort if frequencies are in 1..n. A live stream of “top k so far” is a different structure.

Source. LC 7406809 AUTA R1; TUF 12 live. Full Java: top-k-frequent.

Clue → pattern. Top K by frequency → HashMap + size-K heap (or bucket).

Why this. Count first. Then you only need K extremes, not a full sort of n keys.

Brute. Sort unique keys by freq. Time O(u log u). Space O(n).

Optimal. Min-heap size K on freq, or bucket[freq] lists if freq ≤ n. Time O(n log K). Space O(n).

// freq map then min-heap of [freq, key] size k

Stream “K most frequent so far” is a different running structure (DevBrainiac BR — NMF loop shape).

Merge k sorted linked lists IE-asked

Question they ask. Merge k already-sorted linked lists into one sorted list.

Example. lists = [1→4→5], [1→3→4], [2→6] → 1→1→2→3→4→4→5→6.

Dry run — walk this before you code.

StepWhat you holdResult / why
heap of heads1, 1, 2Next global min is a heap peek, not a scan of k lists each time.
poll 1 (first list)emit 1, offer 4 from that listHeap still size ≤ k.
repeat until emptyEach of N nodes offered onceO(N log k), not concatenate+sort O(N log N).

Say out loud. Use Integer.compare. Pairwise merge is O(kN); heap is tighter when k is not tiny.

Source. LC 7563011 AUTA R2; Bhavya R1. Full Java: merge-k-lists.

Clue → pattern. K sorted lists → min-heap of current heads.

Why this. The next global min is the min of k heads. Heap of size k. Pairwise merge is O(kN); heap is O(N log k).

Brute. Collect all values, sort. Time O(N log N). Space O(N).

Optimal. PriorityQueue<ListNode> of k heads. Time O(N log k). Space O(k).

pq.offer heads; dummy tail; while pq: n=poll; tail.next=n; if (n.next) pq.offer(n.next);

Integer.compare on node.val — do not use b−a.

Maximum Sum Linked List from two sorted lists (common nodes) IE-asked

Question they ask. Two sorted linked lists. Some values appear in both (common nodes). You may switch lists only at a common value. Build the list with the maximum node-sum.

Example. A: 1→3→30→90→120→150. B: 0→3→12→32→90→100→120→180. Commons 3, 90, 120. Take the better segment between commons. You may switch only at a common value. Not LC 962.

Dry run — walk this before you code.

StepWhat you holdResult / why
start → common 3A before 3 is 1; B is 0. Include 3 once.Pick 1+3=4.
3 → 90A middle 30; B middle 12+32=44.Pick 44, then add 90. Do not switch mid-segment.
90 → 120A middle empty; B middle 100.Pick 100, then add 120 once.
after 120A tail 150; B tail 180.Pick 180. Path sum 4+44+90+100+120+180. Two pointers O(n+m). Not LC 962.

Say out loud. Do not stamp LC 962 or LC 210. Delivery-stations topo is a different problem on the same IE.

Source. LC 6881058 / LC 6369243. Do NOT stamp LC 962. Full Java: max-sum-switching-lists.

Clue → pattern. Two sorted lists, may switch only at equal values → two pointers, take better segment.

Why this. Common values are switch points. Accumulate each segment; at a common node take max of the two running sums and reset.

Brute. Enumerate every switch sequence. Time exponential. Space O(1).

Optimal. Two pointers on already-sorted lists O(n+m). Time O(n+m). Space O(1) extra if you relink.

// p, q walk like merge. If p.val < q.val: sumA += p.val; p = p.next;
// else if q.val < p.val: sumB += q.val; q = q.next;
// else /* common */: attach heavier of (segA, segB), then the common once;
//                    reset both segment sums; p = p.next; q = q.next;
// after loop: heavier tail. Do not stamp LC 962.

Not LC 962 / not LC 210. Delivery-stations topo is a sibling on 6369243, different problem.

Grid paths avoiding −1, then max reward IE-asked

Question they ask. Grid, only right and down. Some cells are traps (−1). (1) count paths from top-left to bottom-right. (2) follow-up: max reward on a valid path. OA-as-R1 on that IE — their later “R3” is often this loop’s already-done R2 analogue.

Example. 3×3, traps on some cells, start 0,0 end n-1,n-1.

Dry run — walk this before you code.

StepWhat you holdResult / why
DAGA cell is only reached from left or upDFS without memo repeats work exponentially.
count DPdp[i][j] = 0 if trap else dp[i-1][j]+dp[i][j-1]O(mn).
max DPsame parents, max instead of sum, skip trapsSecond array. Not Unique Paths without rewards.

Say out loud. Say OA-as-R1 remap. Unique Paths II is the count-only sibling.

Source. LC 6800853 AUTA. OA-as-R1: their later live is often this loop’s completed R2 analogue. Full Java: grid-paths-max-reward.

Clue → pattern. Right/down only, traps, count then max → DP.

Why this. DAG moves ⇒ dp[i][j] from left/up. Count ways separately from max score. DFS without memo explodes.

Brute. Recurse every path. Time exponential. Space O(mn).

Optimal. DP count + DP max. Rolling 1D if they want space. Time O(mn). Space O(mn) or O(n).

if (g[i][j]==-1) dp=0; else dp = from_up + from_left;

OA-as-R1 remap. Unique Paths II is the no-reward sibling — Swati similar-not-exact.

Min ops reduce n to 0 subtracting a digit of n IE-asked

Question they ask. Start from n. In one operation subtract one digit that currently appears in n. Minimize operations to reach 0. Example they wrote: n=27 → 5 operations.

Example. n=27. Digits of 27 are 2 and 7. You cannot subtract 9 just because 9 is a digit in general.

Dry run — walk this before you code.

StepWhat you holdResult / why
27options 27−2=25 or 27−7=20BFS, not greedy “always largest digit” unless you prove it.
…Each integer is a state. First time you reach 0 is the min ops.They said 5 for 27. Greedy 27−7=20−2=18… is a path, BFS finds the shortest.
visiteddo not re-queue an integerO(n · digits).

Say out loud. Not Koko (Koko searches a speed). Digits are of the current value.

Source. LC 6800853 same IE. Example n=27 → 5. Full Java: reduce-by-digit.

Clue → pattern. Integer state, unweighted op → BFS. Greedy largest digit is not proven.

Why this. From n you can go to n−d for each digit d of n. Shortest sequence is BFS on integers 0..n.

Brute. Recurse every digit choice. Time exponential with overlap. Space O(n).

Optimal. Queue BFS, dist[x]. Time O(n · digits). Space O(n).

q.offer(n); while: for digit in x: nxt=x-d; if unseen offer

Not Koko. Not “subtract any 1..9.” Digits are of the current value.

Encoded string frequency 1226#24#(2) IE-asked

Question they ask. Parse an encoded string like 1226#24#(2) into letter frequencies (length-26 counts). Do not confuse with Decode Ways (number of interpretations).

Example. Classic mapping: 1=a … 26=z with # for two-digit, and (2) repeats the previous token. Lock their grammar on the example they wrote → they said it becomes something like abzxx family. Use their mapping.

Dry run — walk this before you code.

StepWhat you holdResult / why
walk iread a number / letter / # / (k)This is a parser, not a sliding window.
repeatif (2) multiply the last run into count[c]Do not expand a huge string if they only asked frequencies.
outputint[26]O(n) parse, O(1) extra.

Say out loud. Decode Ways ii (TUF 02) counts interpretations of digits and *. Different family.

Source. LC 6800853 mapped our R1 analogue (OA-as-R1). Full Java: encoded-frequency.

Clue → pattern. Grammar parse → index walk + count[26], not a window.

Why this. #, two-digit letters, and “(2)” repeats are a parser. Expanding the full string can explode. They asked frequencies — multiply into a 26-array.

Brute. Decode fully, then count. Time O(decoded) may be huge. Space O(decoded).

Optimal. Parse O(n), count[26]. Time O(n). Space O(1).

int[] freq = new int[26]; // walk i, handle # and (k)

Not Decode Ways (number of interpretations). TUF 02 Decode Ways ii is a different live title.

Rotten Oranges IE-asked

Question they ask. In a grid, 0 empty, 1 fresh orange, 2 rotten. Every minute, rotten oranges rot 4-neighbors. Return minutes until no fresh left, or −1.

Example. One 2 in the corner and fresh oranges in a chain. Minutes = BFS layers.

Dry run — walk this before you code.

StepWhat you holdResult / why
minute 0put EVERY 2 in the queue (multi-source)DFS from one orange cannot keep a global clock.
minute 1all 1-neighbors of those 2s become 2; fresh−−One layer = one minute.
endif fresh>0 return −1; if nothing was fresh, 0 not −1Ask 4-dir vs 8-dir.

Say out loud. Brute rescan of the whole grid each minute is O((mn)²). Multi-source BFS is O(mn).

Source. igreaper / GFG 2025 / LC 7406809 variation / TUF 11. Mixed OA-as-R1. Full Java: rotten-oranges.

Clue → pattern. Minutes until all rot → multi-source BFS.

Why this. Every rotten orange starts at time 0. Each minute is one BFS layer. DFS cannot keep global time. Fresh count == 0 or −1.

Brute. Rescan the grid every minute. Time O((mn)²). Space O(1).

Optimal. Queue all 2s first; layer BFS. Time O(mn). Space O(mn).

// offer all rotten; while q && fresh: sz=q.size(); minutes++; …

If they said variation, ask 4-dir vs 8-dir and whether already-all-rotten is 0.

Maximal Rectangle of 1s IE-asked

Question they ask. Largest rectangle containing only 1s in a 0/1 matrix (axis-aligned).

Example. One row [1,0,1,1,1] is already a histogram of heights 1,0,1,1,1. Largest 1-height rectangle width 3.

Dry run — walk this before you code.

StepWhat you holdResult / why
row iheight[j] = height[j]+1 if matrix[i][j]==1 else 0Consecutive 1s upward.
histogramlargest rectangle in that height array via next-smaller left/right (monotonic stack)Same stack as NGE, on heights.
max over rowsanswer is the max histogram areaO(mn). Reordering columns is a different TUF HM problem.

Say out loud. Brute all sub-rectangles is O(m²n²). Do not confuse with Largest Submatrix With Rearrangements.

Source. igreaper their R3 = our R2 analogue. Full Java: maximal-rectangle.

Clue → pattern. Largest 1s rectangle → histogram per row + monotonic stack.

Why this. height[j] = consecutive 1s ending at this row. Largest rectangle in histogram is next-smaller left/right via stack.

Brute. All sub-rectangles. Time O(m²n²). Space O(1).

Optimal. O(n) stack per row. Time O(mn). Space O(n).

// for each row update height[]; largestRectangle(height)

Largest Submatrix With Rearrangements (TUF 18 HM) lets you reorder columns — different.

Unique Paths II / obstacle grid DP IE-asked

Question they ask. Count paths from top-left to bottom-right, only right and down, zeros on obstacles.

Example. 2×2 open grid: 2 paths (right-down, down-right). If the end is blocked, 0.

Dry run — walk this before you code.

StepWhat you holdResult / why
dp[0][0]=1unless it is an obstacleBase.
each celldp = from_up + from_left; obstacle forces 0Rolling 1D: dp[j]+=dp[j-1].
max reward follow-updifferent recurrence (max, not sum)Do not reuse the count array as if it were score.

Say out loud. DFS all paths is exponential. Label similar-not-exact if they said similar to Unique Paths II.

Source. TUF 06/10/20; Swati similar-not-exact; LC 7035289 Unique Paths–like BR. Full Java: unique-paths-obstacles.

Clue → pattern. Number of ways right/down with blockers → DP.

Why this. Ways add from left and up. Obstacle zeroes the cell. Rolling 1D is enough.

Brute. DFS all paths. Time exponential. Space O(mn).

Optimal. dp[j] += dp[j-1] with obstacle = 0. Time O(mn). Space O(n).

if (obstacle) dp[j]=0; else if (j>0) dp[j]+=dp[j-1];

Max reward follow-up is a second DP, not the same array. Label similar-not-exact when they said similar.

Course Schedule II / directed cycle IE-asked

Question they ask. n courses, list of prerequisites [a,b] meaning b before a. Return a valid order, or say it is impossible (cycle).

Example. n=2, prereq [1,0] → order [0,1]. If also [0,1], cycle, impossible.

Dry run — walk this before you code.

StepWhat you holdResult / why
indegree0 has indegree 0, 1 has 1Kahn: queue all indegree 0.
take 0reduce 1’s indegree to 0, queue 1Order [0,1].
if leftoverorder.size() < nDirected cycle. Not undirected DSU.

Say out loud. LC 210 was linked on LC 6282609 only. Do not stamp 210 on delivery-stations (LC 6369243).

Source. LC 6282609 linked LC 210 on that post only. TUF 03 Kahn. Full Java: course-schedule.

Clue → pattern. Prereq / can finish → Kahn or DFS colors.

Why this. You can finish iff DAG. Kahn emits an order and detects leftover nodes.

Brute. All permutations. Time O(n!). Space O(n).

Optimal. indegree + queue O(V+E). Time O(V+E). Space O(V+E).

cycle = order.size() < n;

Do not copy 210 onto LC 6369243 delivery stations.

Sliding Window Maximum IE-asked

Question they ask. For every contiguous window of size k, return the maximum in that window.

Example. [1,3,-1,-3,5,3,6,7], k=3 → [3,3,5,5,6,7].

Dry run — walk this before you code.

StepWhat you holdResult / why
window [1,3,-1]max=3. Deque of decreasing indices: 3 then -1Front is the max.
slide, drop 1, add -33 still in window, -1 then -3Max still 3.
add 5pop -3 and -1 (both ≤5); 3 expires if out of windowFront becomes 5. Each index pushed once → O(n).

Say out loud. Scanning each window is O(nk). Heap is O(n log n). Deque is the Live Code answer at n=1e5.

Source. GFG sde1-off-campus R1 story wrap; 1-year-experienced-2 their R3. Full Java: sliding-window-maximum.

Clue → pattern. Max in every window of k → monotonic deque.

Why this. Deque of decreasing indices; front is max; drop expired; drop back if ≤ a[i].

Brute. Scan each window. Time O(nk). Space O(1).

Optimal. ArrayDeque amortized O(n). Time O(n). Space O(k).

// pollFirst expired; pollLast while a[last]<=a[i]; offerLast i

Heap of window is n log n — say deque if n=1e5.

House Robber I → II (circular) IE-asked

Question they ask. Houses in a line: max money, cannot rob two adjacent. Follow-up: houses in a circle (first and last are adjacent).

Example. Linear [1,2,3,1] → 4 (1+3). Circle same array → cannot take both 1s at ends; max of rob(0..n-2) and rob(1..n-1) = 4 still, or 3 on other arrays.

Dry run — walk this before you code.

StepWhat you holdResult / why
linear idp = max(skip = prev, take = prev2 + a[i])O(n) two variables.
circletaking house 0 forbids house n-1Solve two linear ranges, take max.
n=1just a[0]Do not run both ranges empty.

Say out loud. House Robber III is a tree. Do not stamp III on a line.

Source. LC 8029194 R1 named; Sachin R2 LC 213. Full Java: house-robber-ii.

Clue → pattern. Max sum no two adjacent; circular → split.

Why this. Linear is dp: skip or take+prev-skip. Circular forbids both ends → max of two linear ranges.

Brute. 2^n subsets with adjacency check. Time O(2^n). Space O(n).

Optimal. O(n) two linear passes. Time O(n). Space O(1).

return Math.max(robLine(0,n-2), robLine(1,n-1));

House Robber III is tree DP (intern family). Do not stamp III on a linear prompt.

Merge Intervals IE-asked

Question they ask. Given half-open or closed intervals, merge all overlapping ones. Ask inclusive ends.

Example. [1,3],[2,6],[8,10],[15,18] → [1,6],[8,10],[15,18].

Dry run — walk this before you code.

StepWhat you holdResult / why
sort by start1,2,8,15Without sort, overlap is not local.
[1,3] then [2,6]2 ≤ 3 → merge to [1,6]Only the last emitted interval can overlap the next.
[8,10]8 > 6, emit [1,6], start newO(n log n).

Say out loud. Min platforms counts how many overlap at once. That is a different card.

Source. GFG fresher R1; TUF OA also — OA is not a live round. Full Java: merge-intervals.

Clue → pattern. Overlap unions → sort by start, greedy merge.

Why this. After sort, only the last emitted interval can overlap the next.

Brute. Pairwise union-find. Time O(n²). Space O(n).

Optimal. Sort + linear merge. Time O(n log n). Space O(n).

if (iv[i][0] <= cur[1]) cur[1]=max; else emit

Min platforms is concurrent count, not merge.

Minimum Platforms / Meeting Rooms II IE-asked

Question they ask. Trains/meetings with start and end. How many platforms/rooms do you need so no two overlap on one platform?

Example. starts 900, 940, 950. ends 910, 1200, 1120. Need 3 at the peak.

Dry run — walk this before you code.

StepWhat you holdResult / why
sort starts and ends900,940,950 vs 910,1120,1200Sweep.
900: start before 910cur=1Need a new platform.
940: still before 910? 940&gt;910 so an end happens firstcur=0 then start → 1, then 950 before 1120 → 2Max cur is the answer. Heap of end times is the same idea.

Say out loud. This is interval-count DSA, not the Meeting Room Scheduler product in chapter 22.

Source. Prabhash R1; GFG off-campus-10 their R3; TUF 06. Mentor extra-DSA is not 10454435. Full Java: minimum-platforms.

Clue → pattern. How many overlap at once → sweep or min-heap of ends.

Why this. A room/platform frees at the earliest end. Sort starts/ends or heap ends.

Brute. For each meeting scan others. Time O(n²). Space O(1).

Optimal. O(n log n) sweep. Time O(n log n). Space O(n).

if (starts[i] < ends[j]) { cur++; i++; } else { cur--; j++; }

Not the Meeting Room Scheduler product (ch.22). This is the interval-count DSA.

Celebrity Problem IE-asked

Question they ask. In n people, a celebrity is known by everyone and knows nobody. You may call knows(i,j). Find the celebrity or −1.

Example. n=3. 0 knows 1, 1 knows nobody, 2 knows 1. Celebrity is 1 if 0 and 2 both know 1 and 1 knows neither.

Dry run — walk this before you code.

StepWhat you holdResult / why
eliminateif knows(a,i) then a cannot be celebrity, a=i; else i cannotOne call discards one person. O(n).
one survivor sverify: for all i≠s, !knows(s,i) and knows(i,s)If any fail, −1.

Say out loud. Brute is O(n²) matrix. Older Amazon classic, not 2026 AUTA default. Still rehearse.

Source. GFG off-campus-10 year-out remainder. Standard CS classic. Full Java: celebrity.

Clue → pattern. Everyone knows X, X knows nobody → eliminate.

Why this. One knows() discards one person. Verify the survivor’s row/column.

Brute. O(n²) matrix scan. Time O(n²). Space O(1).

Optimal. O(n) eliminate + O(n) verify. Time O(n). Space O(1).

if (knows(a,i)) a=i; then verify

Not 2026 AUTA default. Still rehearse — older Amazon classic.

Min Stack variation (object with size and id) IE-asked

Question they ask. Stack with push/pop/top and getMin in O(1). Variation: the object also carries size and id, not only the min integer.

Example. push 3, push 5, getMin=3, push 2, getMin=2, pop, getMin=3.

Dry run — walk this before you code.

StepWhat you holdResult / why
push 3record (val=3, min=3, id=…)Aux min is copied onto the new top.
push 5min stays 3Top is 5 but getMin peeks the min field = 3.
push 2min becomes 2O(1). A heap would be log n.
popback to 5 with min 3Candidate’s stack+map+PQ is slower than this.

Say out loud. Heap is the wrong DS for O(1) min. Store a record if they want id/size.

Source. TUF 07/09 their R2 (no OA in that write-up). Ch.05 + TUF “more complex Min Stack.” Full Java: min-stack.

Clue → pattern. O(1) min plus extra fields → aux stack of pairs, not a heap.

Why this. Heap is log n. Two stacks: values, and mins (or pairs (val,minSoFar)). Variation asked for size+id on the object — store a record, still O(1) if min is on the aux top.

Brute. Scan the stack each min query. Time O(n) per min. Space O(n).

Optimal. ArrayDeque of records; min field copied down. Time O(1). Space O(n).

st.push(new Rec(x, id, st.isEmpty()?x:Math.min(x, st.peek().min)));

Candidate tried stack+map+PQ — say why that is slower than aux min.

LRU Cache IE-asked

Question they ask. Cache of capacity cap. get(key) and put(key,val) in O(1). Evict the least recently used key when full. If they say LFU, that is frequency buckets — TUF 15 URL vs body conflict, ask.

Example. cap=2. put 1, put 2, get 1, put 3 → 2 is evicted because 1 was used more recently.

Dry run — walk this before you code.

StepWhat you holdResult / why
HashMap key→nodeO(1) findNeed the node to splice.
DLL most-recent at headget/put: remove node, add to frontOrder is the recency list.
over capevict tail.prev, delete from mapNot Login Tracker (unverified).

Say out loud. LinkedHashMap only if you know access-order + removeEldest. Prefer HashMap+DLL in Live Code.

Source. Bhavya Hyd Interview 2; TUF 15 linked LRU but body said LFU — write the conflict. Full Java: lru-cache.

Clue → pattern. O(1) get/put eviction of least recent → HashMap + DLL.

Why this. Hash finds the node; DLL splice is O(1) move-to-front. LinkedHashMap access-order is the library version — they often want the hand-rolled pair.

Brute. List scan to find / evict. Time O(n). Space O(n).

Optimal. HashMap<Integer,Node> + dummy head/tail. Time O(1). Space O(capacity).

// remove(node); addFront(node); if size>cap evict tail.prev

Not Login Tracker (unverified). If they said LFU, add freq buckets.

Open the Lock (similar) IE-asked

Question they ask. 4-digit lock, each wheel 0–9 wrap. Deadends blocked. Min turns from 0000 to target, or −1. Similar-to on that IE — confirm exact IO.

Example. target 0202, a few deadends. Each move changes one digit ±1.

Dry run — walk this before you code.

StepWhat you holdResult / why
state0000 … 9999, 8 neighbors eachUnweighted → BFS, not DFS.
deadendnever queueVisited set.
first time you see targetthat distance is min turnsSimilar-to Open the Lock; same IE also had Distance K in Fluency.

Say out loud. Do not stamp LC 752 unless they linked it.

Source. LC 7623949 similar to Open the Lock. Full Java: open-lock.

Clue → pattern. 4-digit wheel, deadends, min turns → BFS on strings/ints.

Why this. Unweighted moves (±1 on one digit). Deadends are blocked nodes. DFS is not shortest.

Brute. All sequences. Time exponential. Space O(10^4).

Optimal. BFS, 10000 states. Time O(10000 · 8). Space O(10000).

// state as int 0..9999; ±1 on each digit with wrap

Similar-to, not stamped as exact LC 752 unless they linked it. This post also had Distance K in Fluency.

Max path between two leaves / two-leaves path IE-asked

Question they ask. Maximum path sum between two leaves (not the any-node path that can start in the middle). Do not clamp a negative child to zero the way LC 124 does.

Example. A node with left leaf 3 and right leaf −1: through-node sum is 3+(node)+(−1) if both sides must be leaves. Ask if a single child still counts as a leaf-path.

Dry run — walk this before you code.

StepWhat you holdResult / why
at node uneed a best downward chain to a leaf on left and on rightThrough-u = leftDown + u.val + rightDown.
return to parentone best downward leaf-chainGlobal max of through-u.
trapmax(0, child) is the ANY-NODE problemLeaf-to-leaf must keep the child even if negative, if both sides are required.

Say out loud. Paste-only until the bible has a URL. Ask the leaf constraint out loud.

Source. ch.05 max-path-between-leaves; _answers/09-dsa-new-ies.md. Full Java: max-path-between-leaves.

Clue → pattern. Path value through a node using two child heights → tree DP.

Why this. At each node, best path that goes through it is left-gain + right-gain + val. Return the best downward gain to the parent.

Brute. All leaf pairs. Time O(n²). Space O(n).

Optimal. One DFS. Time O(n). Space O(h).

int down = val + max(0, max(L,R)); global = max(L+R+val);

Diameter in hops vs weighted path — ask which.

Remove K Digits IE-asked

Question they ask. Remove exactly k digits from a number-string so the remaining number is the smallest possible. Keep order. Strip leading zeros.

Example. num=1432219, k=3 → 1219 (drop 4,3,2).

Dry run — walk this before you code.

StepWhat you holdResult / why
read 1,44 > later 3 and we still have deletions: pop 4A larger digit in a more significant place is worse.
3 then 2pop 3, pop 2 while k>0Monotone increasing stack.
219 left + leftover kif k still left, pop from the tailThen strip zeros. Intern DesiQnA is INTERN, not your third live.

Say out loud. Maximize instead of minimize flips the compare. Phone LC 6630775 is OA-as-R1 remap.

Source. LC 6630775 phone (OA-as-R1 remap). Intern DesiQnA Set-61 = INTERN. Full Java: remove-k-digits.

Clue → pattern. Delete k digits, smallest number → increasing monotonic stack.

Why this. A larger digit in a more significant place is worse if you can still delete.

Brute. All subsets of deletions. Time C(n,k). Space O(n).

Optimal. Stack O(n). Strip leading zeros. Time O(n). Space O(n).

while (k>0 && !st.isEmpty() && st.peek()>c) { st.pop(); k--; }

Maximize instead of minimize flips the compare.

Most frequent subtree sum IE-asked

Question they ask. For every node, subtree sum = node + left + right. Return the subtree-sum value(s) that occur most often.

Example. A small tree where two subtrees both sum to 2 → answer [2].

Dry run — walk this before you code.

StepWhat you holdResult / why
postordersum = val + dfs(left)+dfs(right)One visit per node, not rescan.
HashMap sum→counttrack the max countThen collect keys with that count.

Say out loud. Equal-split tree wants total/2, not the mode. Different card.

Source. ch.05 most-frequent-subtree-sum. Full Java: most-frequent-subtree-sum.

Clue → pattern. Subtree sums + frequencies → postorder + HashMap.

Why this. A subtree sum is left+right+val. Count those sums; take the mode.

Brute. For each node rescan the subtree. Time O(n²). Space O(n).

Optimal. One postorder; map sum→count. Time O(n). Space O(n).

int sum = u.val + dfs(u.left) + dfs(u.right); freq.merge(sum,1,Integer::sum);

Equal-split tree wants total/2, not the mode of sums.

Longest increasing path in a matrix IE-asked

Question they ask. Longest strictly increasing path in a matrix; from a cell you may walk 4-dir to a strictly larger neighbor. Do not stamp LC 329 as Job 10454435.

Example. A cell 1 next to 2 next to 9 → length 3 if that chain is the longest.

Dry run — walk this before you code.

StepWhat you holdResult / why
not Unique Paths DPmoves are not a DAG from the origin; you can go any 4-dir as long as increasingMemo DFS from each cell.
memo[i][j]1 + max(legal neighbors), or 1 if noneEach cell computed once → O(mn).

Say out loud. Prince right/diag max-sum is a different DAG. Year-out GFG BR.

Source. ch.05 longest-increasing-path-matrix. Full Java: longest-increasing-path-matrix.

Clue → pattern. 4-dir increasing path → memo DFS, not Unique Paths DP.

Why this. Moves are not a DAG from origin; they are “to a strictly larger neighbor.” Memoize best path from each cell.

Brute. DFS every path. Time exponential. Space O(mn).

Optimal. memo[i][j] = 1+max(legal neighbors). Time O(mn). Space O(mn).

if (memo[i][j]!=0) return memo[i][j];

Prince right/diag max-sum is a different DAG DP. Do not stamp Falling Path as identical.

Kth ancestor (even / binary lifting family) IE-asked

Question they ask. Sum (or list) of nodes whose k-th ancestor is even — year-out GFG twist. First you need k-th parent of each node.

Example. Root 1, child 2, grandchild 4, k=1: 4’s 1st ancestor is 2 (even) → include 4.

Dry run — walk this before you code.

StepWhat you holdResult / why
parent[] from DFSwalk k times is O(k) per nodeToo slow if k and n large.
binary liftingup[v][j] = 2^j parentO(n log n) preprocess, O(log k) query. If they said “even”, apply after you have the ancestor.

Say out loud. Year-out. Do not invent LC 1483 as this Job ID.

Source. ch.05 kth-ancestor-even. Full Java: kth-ancestor-even.

Clue → pattern. Repeated parent hops → binary lifting or climb.

Why this. k jumps on parent[] is O(k). Precompute up[i][p] = 2^p parent for O(log k).

Brute. Walk parent k times per query. Time O(q k). Space O(n).

Optimal. Binary lifting O(n log n) preprocess, O(log k) query. Time O(n log n + q log k). Space O(n log n).

// up[v][0]=parent; up[v][j]=up[ up[v][j-1] ][j-1]

If they said a twist (“even”), stay with their constraint; do not invent LC 1483 as Job 10454435.

Distance between two nodes / LCA then path IE-asked

Question they ask. Distance between two nodes in a binary tree (shortest path unique).

Example. A and B with LCA L. dist = depth[A]+depth[B]−2·depth[L].

Dry run — walk this before you code.

StepWhat you holdResult / why
find LCAone DFSO(n).
depths from rootor dist from LCA down to eachTUF 11 named this. LCA II/III are pointer variants.

Say out loud. If they ban a parent map, pass parent as an argument like Distance K.

Source. TUF 11 Binary Tree Shortest Path; ch.05 distance-two-nodes. Full Java: distance-two-nodes.

Clue → pattern. Two nodes on a tree → LCA, dist = d(a)+d(b)−2d(lca).

Why this. Unique path. Find LCA; depths from root or from LCA.

Brute. BFS from A to B after building undirected. Time O(n). Space O(n).

Optimal. One or two DFS. Same O(n). Time O(n). Space O(n).

// dist(u,v) = depth[u]+depth[v]-2*depth[lca]

LCA II/III TUF 14/21 are node-pointer variants (parent pointers on III).

Stack get-middle IE-asked

Question they ask. Stack that also returns the middle element in O(1) (or O(1) delete middle — ask).

Example. push 1,2,3,4,5. Middle is 3. pop → middle becomes 3 or 2 depending on even/odd rule — lock it.

Dry run — walk this before you code.

StepWhat you holdResult / why
DLL + mid pointeron push, if size becomes odd, mid = mid.nextArrayDeque has no O(1) middle.
popmove mid the other way on parityjava.util.Stack is legacy anyway.

Say out loud. Do not use ArrayList get(mid) if they also want O(1) push at the front of a vector — DLL is the intended structure.

Source. ch.05 stack-get-middle. Full Java: stack-get-middle.

Clue → pattern. Push/pop + get mid → DLL + mid pointer, or two structures.

Why this. ArrayList get mid is O(1) but pop front is O(n). DLL with a mid pointer moves mid on size parity.

Brute. Vector + index mid each time O(n) push at 0. Time O(n). Space O(n).

Optimal. DLL + mid. O(1) all if they allow custom nodes. Time O(1). Space O(n).

// if size odd after push, mid = mid.next; pop reverse

java.util.Stack is legacy. ArrayDeque has no O(1) middle.

Next Permutation IE-asked

Question they ask. Rearrange the array into the next lexicographic permutation. If already last, reverse to the first. “Next greater with same digits” is this, not NGE stack.

Example. [1,2,3] → [1,3,2]. [3,2,1] → [1,2,3].

Dry run — walk this before you code.

StepWhat you holdResult / why
from the rightfind first descent a[i] < a[i+1] (pivot)Right of pivot is non-increasing.
swap pivot with rightmost a[j] &gt; a[i]then reverse the suffixO(n) in-place. Not a stack of next-greater values.

Say out loud. Prabhash mixed this wording with NGE. Ask: next permutation or next greater element?

Source. AUTA LC 6806195 similar; Prabhash next greater same digits. Full Java: next-permutation.

Clue → pattern. Next lexicographic arrangement → pivot from right, swap, reverse suffix.

Why this. Longest non-increasing suffix is already the last perm of those digits. Pivot is the left descent; swap with the rightmost successor; reverse suffix.

Brute. Generate all perms, pick next. Time O(n!). Space O(n!).

Optimal. O(n) in-place. Time O(n). Space O(1).

// i from n-2 while a[i]>=a[i+1]; swap with rightmost > a[i]; reverse i+1..end

Not NGE stack. “Same digits” wording is this, not next greater element.

Count of smaller numbers after self IE-asked

Question they ask. For each index i, count how many j > i have a[j] < a[i]. NMF / year-out — label it. Do not treat as AUTA default.

Example. [5,2,6,1] → [2,1,1,0].

Dry run — walk this before you code.

StepWhat you holdResult / why
brutenested j>iO(n²).
merge-sort / Fenwick on ranks, right to leftcount of already-seen smallerO(n log n).

Say out loud. If the IE was US/FTC, NMF. Fenwick is rare SDE I — still know the inversion idea.

Source. ch.05 count-smaller-after-self. Bible / 09-dsa-new-ies: NMF or year-out — label it. Full Java: count-smaller-after-self.

Clue → pattern. For each i, count j>i with a[j]

Why this. Inversion-like. Brute n². Merge sort while counting right-half smaller, or Fenwick on ranks.

Brute. Nested j>i. Time O(n²). Space O(1).

Optimal. O(n log n) merge or BIT. Time O(n log n). Space O(n).

// fenwick on compressed ranks, iterate right to left

NMF-possible (Hyderabad onsite paste; not UTA two-DSA default). Candidate named LC 315 on that paste — do not copy that id onto unnamed “count smaller” prompts. Not a 10454435 forecast.

Minimum / generalized Knight Moves IE-asked

Question they ask. Min knight hops from a square to a target (infinite board or chessboard — ask). Generalized deltas: same BFS, different DIRS.

Example. From (0,0) to (2,1) is 1 hop on a standard knight.

Dry run — walk this before you code.

StepWhat you holdResult / why
8 deltas(±1,±2) and (±2,±1)Unweighted → BFS.
symmetryyou can BFS in one quadrant if infiniteRace Car is a different state (position, speed).

Say out loud. DFS depth-limit is exponential. BFS on visited cells.

Source. LC 6629948 Minimum Knight Moves; ch.05 generalized-knight-moves. Full Java: generalized-knight-moves.

Clue → pattern. Knight on infinite/chess board min hops → BFS.

Why this. Unweighted hops. Symmetric — you can BFS in one quadrant. Generalized deltas: same BFS, different DIRS.

Brute. DFS depth-limit. Time exponential. Space O(visited).

Optimal. BFS O(cells reached). Time O(area). Space O(area).

int[][] K = {{1,2},{1,-2},{-1,2},{-1,-2},{2,1},{2,-1},{-2,1},{-2,-1}};

Race Car is a different BFS-on-state (position, speed) — GFG sde-1-34.

Partition to target / combination sum family IE-asked

Question they ask. Can you pick a subset that sums to target T? (Or list partitions — ask.)

Example. [1,5,11,5], T=11 → yes (11, or 5+5+1).

Dry run — walk this before you code.

StepWhat you holdResult / why
n smallbacktrack 2^nOK if n≤20.
T not hugeboolean dp[x] |= dp[x−a[i]]0/1 knapsack O(nT).

Say out loud. Factor Combinations is backtracking on factors, not subset-sum.

Source. ch.05 partition-target-combination. Full Java: partition-target-combination.

Clue → pattern. Can you pick a subset summing to T → DP knapsack or backtrack if n small.

Why this. 0/1 knapsack boolean dp[t]. Backtrack if they want the actual partitions.

Brute. All subsets. Time O(2^n). Space O(n).

Optimal. dp[x] |= dp[x−a[i]]; O(nT). Time O(nT). Space O(T).

boolean[] dp = new boolean[t+1]; dp[0]=true;

Factor Combinations TUF 201 BR is backtracking on factors, not subset-sum.

Device capability (pasted-IE family) IE-asked

Question they ask. Pasted-IE family. Open chapter 05. Do not invent a LeetCode id. Remap in chapter 18 before treating it as your third live.

Example. Capability / version numbers usually sort + greedy or binary search on a threshold. Use their paste.

Dry run — walk this before you code.

StepWhat you holdResult / why
askwhat is a valid assignment?Unnamed paste stays unnamed.
thenopen 05-dsa.html#device-capabilityNot a 10454435 lock.

Say out loud. Do not restamp a random LC.

Source. ch.05 device-capability — remap in ch.18 before treating as your third live. Full Java: device-capability.

Clue → pattern. Read the pasted stem. Do not invent a LeetCode id.

Why this. Capability / version gating is usually sort + greedy or BS on answer. Open the ch.05 card; stay with their constraints.

Brute. Depends on the paste. Time see ch.05. Space see ch.05.

Optimal. See chapter 05 — do not restamp. Time see ch.05. Space see ch.05.

// open 05-dsa.html#device-capability

Pasted IE ≠ Job 10454435. OA-as-R1 remap in chapter 18.

Server partitions (pasted-IE family) IE-asked

Question they ask. Pasted-IE. Split / load servers. If “minimize the max load”, that is binary search on answer. If machines are a graph, DSU.

Example. Lock IO from the paste.

Dry run — walk this before you code.

StepWhat you holdResult / why
minimize maxfeasible(M) = can we pack into ≤ k bins of size MSame family as ship packages.
componentsflood or DSUDifferent.

Say out loud. Open chapter 05. Unnamed paste.

Source. ch.05 server-partitions. Full Java: server-partitions.

Clue → pattern. Split servers / load → often minimize-max BS or greedy pack.

Why this. If the paste is “partition so max load is minimized,” that is BS on answer. If it is connected components of machines, DSU.

Brute. see ch.05 Time see ch.05. Space see ch.05.

Optimal. see ch.05 Time see ch.05. Space see ch.05.

// open 05-dsa.html#server-partitions

Unnamed paste stays unnamed. Not a 10454435 lock.

Loyal customer logs (pasted-IE family) IE-asked

Question they ask. Pasted logs: customer id + day. “Loyal” usually means seen on ≥ k distinct days or in a window. Ask the definition.

Example. Do not invent a metric.

Dry run — walk this before you code.

StepWhat you holdResult / why
parsemap customer → set of daysHashMap<id, HashSet<day>> or TreeSet.
filtersize ≥ kO(n).

Say out loud. Not Nisarg’s k-page sequence unless they said pages.

Source. ch.05 loyal-customer-logs. Full Java: loyal-customer-logs.

Clue → pattern. Logs + customer ids + dates → HashMap of sets / sliding on days.

Why this. “Loyal” usually means appeared on ≥k distinct days or in a window. Parse, then map customer → TreeSet of days.

Brute. see ch.05 Time see ch.05. Space see ch.05.

Optimal. see ch.05 Time see ch.05. Space see ch.05.

// open 05-dsa.html#loyal-customer-logs

Do not invent a metric. Ask the definition of loyal.

Logger message global IE-asked

Question they ask. shouldPrintMessage(t, msg): print if this message was not printed in the last 10 seconds. Not the distributed Rate Limiter (count = 1, not UTA).

Example. print foo at t=1, again at t=2 → false, at t=11 → true.

Dry run — walk this before you code.

StepWhat you holdResult / why
map msg→lastPrintif t < last+10 return false else updateO(1) average.
not Redissingle process HashMapDo not upgrade to Kafka on a two-DSA loop.

Say out loud. Classic logger rate limit. Related to logger LLD, not Login Tracker.

Source. ch.05 logger-message-global. Related to logger LLD in bible §5.C Reddit 1ueybmg. Full Java: logger-message-global.

Clue → pattern. Rate-limit messages / shouldPrintMessage → HashMap timestamp.

Why this. Classic LC 359 family: map message→last print; allow if t >= last+10. This is not the distributed Rate Limiter (count = 1, not UTA).

Brute. List of all prints, scan. Time O(n). Space O(n).

Optimal. HashMap O(1) average. Time O(1). Space O(#messages).

if (!map.containsKey(m) || t >= map.get(m)+10) { map.put(m,t); return true; }

Do not upgrade this to Redis/Kafka HLD on a two-DSA loop.

Basic calculator OOD / expression IE-asked

Question they ask. Evaluate + − * / and/or parentheses. Ask which operators. RPN (TUF 17) is postfix — different card.

Example. 2-1+2 = 3. (1+(4+5+2)-3)+(6+8) = 23.

Dry run — walk this before you code.

StepWhat you holdResult / why
+ − and parensone number, one sign, a stack of signs when you see '('On ')' pop until '('.
* /hold the last number and apply immediately (higher precedence)Do not use eval().

Say out loud. OOD wrap is Strategy for ops only if they asked classes.

Source. ch.05 basic-calculator-ood. Full Java: basic-calculator-ood.

Clue → pattern. Parse +−*/ or nested parens → stack of signs / nums.

Why this. One pass with a sign stack handles +− and parens. * / need a tighter last-number hold. OOD wrap is Strategy for ops if they asked classes.

Brute. Eval with a library — they will refuse. Time —. Space —.

Optimal. Stack O(n). Time O(n). Space O(n).

// sign, num, stack; on +− flush; on ( push sign

Evaluate RPN TUF 17 is the postfix sibling — stack of values, not infix.

2. Bible §5.A remainder (deduped against §1)

Still other candidates, still not Job 10454435. OA-as-R1 flagged on the source line when the bible says so.

Count Complete Subarrays IE-asked

Question they ask. A subarray is complete if it contains every distinct value that appears in the whole array. Count them. GFG 2025 first live (OA-as-R1).

Example. Array with global distinct = 3. Once a window already holds all 3, every extension to the right is also complete.

Dry run — walk this before you code.

StepWhat you holdResult / why
global Dnumber of unique in the whole arrayNeed window size of HashMap == D.
expand r until need metthen ans += n−r (all ends from r to n-1)Shrink left to count more windows. O(n).

Say out loud. OA-as-R1: their later Connect Sticks + Rotten is often our R2 analogue.

Source. GFG 2025 off-campus. OA-as-R1 first live.

Clue → pattern. Complete = contains all distinct of the whole array → window at-most / two pointers on distinct.

Why this. Once the window holds every global distinct, every extension to the right is also complete. Count with a shrink/expand on HashMap size vs global size.

Brute. All L,R; HashSet slice vs global. Time O(n²). Space O(Σ).

Optimal. O(n) window. Time O(n). Space O(Σ).

// let need = global distinct; expand r until size==need; ans += n-r; shrink

OA-as-R1: their “R3” Connect Sticks + Rotten is often our R2 analogue.

Daily Temperatures–like monotonic stack IE-asked

Question they ask. For each day, how many days until a warmer temperature? If none, 0. Same stack as NGE, answers are distances.

Example. [73,74,75,71,69,72,76,73] → [1,1,4,2,1,1,0,0].

Dry run — walk this before you code.

StepWhat you holdResult / why
73next 74 is 1 dayans=1.
75next warmer 76 is 4 days laterStack of indices, decreasing temps.

Say out loud. Naina UTA R1 similar-to. Second R1 problem was UNNAMED — do not invent it.

Source. Naina Medium UTA R1 12 Jun 2025.

Clue → pattern. Days until a warmer temperature → NGE distances.

Why this. Same decreasing stack; store index; answer[i] = j−i.

Brute. O(n²) scan. Time O(n²). Space O(1).

Optimal. O(n) stack. Time O(n). Space O(n).

ans[st.pop()] = i - st.peek() /* after pop compare */;

Second R1 problem was UNNAMED logic-heavy — do not invent it.

Path Sum–like tree IE-asked

Question they ask. Path-sum–like on a tree (Akash snippet). Ask: root-to-leaf equals target, or any path?

Example. Root-to-leaf: subtract node val, at a leaf check remaining==0.

Dry run — walk this before you code.

StepWhat you holdResult / why
root-to-leafDFS remainingO(n).
any pathprefix sums on the tree + HashMap (path sum III family)They said similar. Ask.

Say out loud. Snippet only. Similar-not-exact.

Source. Akash LinkedIn AUTA Jan 2026 snippet.

Clue → pattern. Root-to-leaf or any-path sum → DFS remaining.

Why this. Subtract node val; at leaf check 0. Any-path is prefix + HashMap on the tree (path sum III family) — they said similar; ask.

Brute. All paths. Time O(n²). Space O(h).

Optimal. DFS O(n) for root-to-leaf. Time O(n). Space O(h).

boolean dfs(u, left) { if (u==null) return false; if (leaf && left==u.val) return true; }

Snippet only. Similar-not-exact.

Currency Converter (graph) IE-asked

Question they ask. Equations a/b = w. Query x/y as a product along a path, or −1 if disconnected. TUF Evaluate Division similar.

Example. a/b=2, b/c=3, query a/c → 6.

Dry run — walk this before you code.

StepWhat you holdResult / why
edge a→b weight 2, b→a 1/2graph of currenciesDFS/BFS multiply.
disconnectedreturn −1Not a sliding window.

Say out loud. Shiwangi UTA R1. Do not invent FX APIs.

Source. Shiwangi Medium UTA R1. TUF 01 Evaluate Division similar.

Clue → pattern. a/b = w equations, query product → weighted DFS/BFS.

Why this. Each equation is a bidirectional edge with weight w and 1/w. Query is a path product. HashMap of adj.

Brute. Try all conversion sequences. Time exponential. Space O(V+E).

Optimal. DFS/BFS per query or Floyd if few currencies. Time O(V+E) per query. Space O(V+E).

// adj.get(a).add({b,w}); adj.get(b).add({a,1/w}); dfs multiply

TUF linked Evaluate Division — similar. Do not invent extra FX APIs.

Number of Islands IE-asked

Question they ask. Count 4-connected groups of '1' land in a grid.

Example. Two blobs separated by water → 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
scaneach unvisited '1' starts a flood, islands++DFS or BFS, mark visited (often in-place '0').
doneO(mn)Max-area / distinct-islands are follow-ups, not assumed.

Say out loud. AUTA LC 8362604 R1 / Deepak.

Source. LC 8362604 AUTA R1; Deepak Jul 2026.

Clue → pattern. Grid components → flood DFS/BFS.

Why this. Each unvisited land starts a component. Mark visited in-place.

Brute. Union every adjacent pair with a slow structure. Time O(mn α). Space O(mn).

Optimal. DFS flood O(mn). Time O(mn). Space O(mn) stack worst.

if (g[i][j]=='1') { dfs; islands++; }

Max area / distinct islands are follow-ups, not assumed.

Median of Data Stream IE-asked

Question they ask. Insert numbers over time; after each insert (or on query) return the median.

Example. 1, then 2 → median 1.5; then 3 → median 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
low max-heap, high min-heapall in low ≤ all in high; sizes differ by ≤1Median is low.peek or average of both peeks.
rebalanceif low is too big, move to highO(log n) insert, O(1) median. Sorting a list each time is O(n).

Say out loud. Integer overflow on (a+b)/2 — use /2.0 after peek.

Source. LC 8362604 AUTA R1; LC 6475219.

Clue → pattern. Running median → two heaps.

Why this. Low max-heap, high min-heap; sizes differ by ≤1. Rebalance on insert.

Brute. Keep a sorted list, insert O(n). Time O(n) per add. Space O(n).

Optimal. Two PriorityQueues. Time O(log n) add, O(1) median. Space O(n).

// if x<=low.peek() low else high; then rebalance sizes

Integer overflow on (a+b)/2 — use /2.0 after peek.

Generate all subsets IE-asked

Question they ask. Generate every subset of an array (power set). n is small.

Example. [1,2] → [], [1], [2], [1,2].

Dry run — walk this before you code.

StepWhat you holdResult / why
each elementinclude then recurse, skip then recurseOutput size 2^n is required, not a fail.
n≤20backtrackingCount of subsets with a constraint is DP instead.

Say out loud. AUTA LC 7406809 R1 linked.

Source. LC 7406809 AUTA R1 LC-linked.

Clue → pattern. All combinations of include/skip → backtracking.

Why this. n ≤ ~20. Each element in or out. Output size 2^n is required.

Brute. Same exponential, generate then unique. Time O(2^n · n). Space O(n).

Optimal. Choose/skip recurse. Time O(2^n · n). Space O(n).

path.add; recurse i+1; path.remove; recurse i+1;

Count of subsets with a constraint is DP, not this.

Koko / Capacity to Ship Packages / BS-on-answer family IE-asked

Question they ask. Minimum eating speed / ship capacity so you finish in ≤ H hours/days. Binary search the answer, not the index.

Example. Piles [3,6,7,11], H=8 → min speed 4 (Koko family). Capacity to ship packages is the same monotone feasible.

Dry run — walk this before you code.

StepWhat you holdResult / why
lo=1, hi=max pile (or sum)mid = candidate speedfeasible(mid): hours = sum of ceil(pile/mid); hours ≤ H.
if feasible, try smallerelse raise loO(n log RANGE). Heap does not replace this.

Say out loud. TUF 13 Smallest Divisor and TUF 16 Bouquets are the same family. Naina UTA R2 Koko-like.

Source. Naina UTA R2 Koko-like; LC 6806195 Ship Packages AUTA; TUF 07/09 Koko (no OA in that IE).

Clue → pattern. Min speed/capacity so hours/days ≤ H → BS on answer + feasible.

Why this. Larger capacity always succeeds if smaller does. feasible is a linear pack. Heap is the wrong first tool.

Brute. Try every speed 1..max. Time O(MAX · n). Space O(1).

Optimal. O(n log RANGE). Time O(n log RANGE). Space O(1).

if (feasible(mid)) { ans=mid; hi=mid-1; } else lo=mid+1;

TUF 13 Smallest Divisor and TUF 16 Min Days Bouquets are the same family.

Asteroid Collision (similar) IE-asked

Question they ask. Asteroids on a line: positive go right, negative left. Same magnitude: both explode; smaller abs explodes.

Example. [5,10,-5] → [5,10] (−5 explodes). [8,-8] → empty.

Dry run — walk this before you code.

StepWhat you holdResult / why
5,10 going rightstack 5,10No fight yet.
−5fights 10: |5|<10, −5 dies10 stays. While incoming is left-going and top is right-going, compare abs.

Say out loud. Similar-to on AUTA 6806195. Intern TUF 104 is INTERN.

Source. LC 6806195 similar R1; Parimal ~Apr 2026 named; TUF 16 live; intern TUF 104.

Clue → pattern. Opposite directions destroy → stack of survivors.

Why this. A right-mover waits. A left-mover fights the stack top while the top is smaller and right-going.

Brute. Rescan the list after each collision. Time O(n²). Space O(n).

Optimal. ArrayDeque O(n). Time O(n). Space O(n).

while (!st.isEmpty() && incoming<0 && st.peek()>0) { /* compare abs */ }

Similar-to on 6806195. Intern 104 is INTERN.

Similar to Cheapest Flights Within K Stops IE-asked

Question they ask. n cities, flights [from, to, price], src, dst, and at most k stops (so ≤ k+1 edges). Cheapest price, or −1. Similar-to — lock their k meaning (stops vs edges).

Example. n=4, flights 0→1 cost 100, 1→2 cost 100, 0→2 cost 500, 0→3 cost 100, 3→2 cost 100, src=0, dst=2, k=1 stop. Direct 0→2 is 500. Path 0→1→2 uses 1 stop and costs 200. Path 0→3→2 also 1 stop, cost 200.

Dry run — walk this before you code.

StepWhat you holdResult / why
k meaningk=1 stop ⇒ at most 2 edgesDijkstra on cost only may take a cheap 3-edge path that is illegal.
round 0dist[src]=0, others INF0 edges used.
relax 1 edge0→1=100, 0→2=500, 0→3=100dst is 500 so far.
relax 2nd edge (k=1)1→2 makes 200; 3→2 makes 200Answer 200. Copy the dist array each round so you do not chain extra hops in one round.

Say out loud. State is (node, stops). Bellman k+1 rounds or PQ on (cost, node, stops). Do not stamp LC 787 as exact.

Source. LC 7850431 snippet R1.

Clue → pattern. Weighted graph, at most K edges → BFS/Bellman relax K+1 times, not plain Dijkstra.

Why this. Dijkstra without a stop dimension can take a cheap long path that uses too many stops. State is (node, stops).

Brute. All walks with ≤K edges. Time exponential. Space O(V).

Optimal. Relax E edges K+1 rounds or PQ on (cost,node,stops). Time O(K · E). Space O(K V).

int[] dist = new int[n]; Arrays.fill(dist, INF); dist[src] = 0;
for (int i = 0; i <= k; i++) {
  int[] nd = dist.clone();
  for (int[] e : flights) if (dist[e[0]] < INF) nd[e[1]] = Math.min(nd[e[1]], dist[e[0]] + e[2]);
  dist = nd;
}
return dist[dst] == INF ? -1 : dist[dst];

Snippet “similar to.” Do not stamp LC 787 as exact. Dijkstra without a stop dimension is the trap.

Power allocation max-min (BS-on-answer) IE-asked

Question they ask. Allocate power/resource to n parts. Maximize the minimum any part gets. Ask the exact constraint (sum ≤ budget, or stations on a line).

Example. Stalls/positions [1, 2, 4, 8, 9], place 3 cows, maximize min gap. Same monotone as Aggressive Cows / chapter 25.

Dry run — walk this before you code.

StepWhat you holdResult / why
lo, himin gap 1 .. (9−1)=8Monotone: if gap T is feasible, T−1 is too.
T=3Place at 1, then 4, then 8Fits 3. Try higher.
T=41, then 8, then cannot place 3rd with gap 4Infeasible. Answer 3.
power versionfeasible(T) = can every part get ≥ T under their budget ruleAsk the rule before coding.

Say out loud. Binary search the answer. Greedy place / pack is the check. Snippet — lock the assignment constraint.

Source. LC 7850431 snippet R1.

Clue → pattern. Maximize the minimum allocation → BS on T + feasible.

Why this. Same maximize-minimum card as chapter 25.

Brute. Try every T. Time O(MAX · n). Space O(1).

Optimal. O(n log RANGE). Time O(n log RANGE). Space O(1).

// feasible(T): can we assign so every part >= T

Snippet. Ask the assignment constraint out loud.

Detonate the Maximum Bombs IE-asked

Question they ask. Bombs at (x,y) with radius r. Detonating i detonates every j with distance ≤ r[i]. Max bombs in one chain.

Example. A at (0,0) r=2; B at (1,0) r=1; C at (10,0) r=1. A reaches B (dist 1 ≤ 2). B does not reach A if dist 1 > r[B]? 1≤1, yes. C is alone.

Dry run — walk this before you code.

StepWhat you holdResult / why
directed?A→B if dist ≤ r[A], not necessarily B→AAsymmetric. Confirm Euclidean vs Manhattan.
buildedge A→B, B→A; C isolatedO(n²) pair test.
DFS from AA,B — count 2From C count 1. Answer 2.

Say out loud. Graph + DFS/BFS from each start. O(n²). Not a union-find unless radii are symmetric.

Source. LC 7724048 snippet R1.

Clue → pattern. Bomb i reaches j if dist ≤ radius → directed graph, DFS/BFS count.

Why this. Asymmetric radii ⇒ directed edges. From each start, count reachable. O(n²) build + O(n) search.

Brute. Same O(n²) to test pairs — that is also the build. Time O(n³) naive recompute. Space O(n²).

Optimal. Build adj O(n²), DFS each source O(n²). Time O(n²). Space O(n²).

// if dist2 <= r*r add edge i→j; dfs count

Snippet. Confirm Euclidean vs Manhattan.

Diameter of Binary Tree variation IE-asked

Question they ask. Longest path in a binary tree (or a general tree). Ask: hop count vs weighted edges; binary vs n-ary.

Example. Tree 1—2—3 with 2 also having child 4. Longest path 3-2-4 or 3-2-1, length 2 hops.

Dry run — walk this before you code.

StepWhat you holdResult / why
at node 2height(left)=1 (node 3 or 1), height(right)=1 (4)d = max(d, 1+1)=2.
return height1 + max(child heights)One DFS. All-pairs BFS is the brute.
general treetwo BFS: farthest from arbitrary, then farthest from thatIf they drew an unrooted tree.

Say out loud. Ask hop vs weight. Variation — do not assume LC 543 wording.

Source. LC 7280347 13 Aug 2025.

Clue → pattern. Longest path in a tree → two heights or two BFS.

Why this. See chapter 25 tree-diameter.

Brute. All pairs. Time O(n²). Space O(n).

Optimal. One DFS heights. Time O(n). Space O(h).

d = max(d, leftH+rightH); return 1+max(leftH,rightH);

Variation — ask hop vs weight.

Uni-valued subtrees; Search in Rotated Sorted Array IE-asked

Question they ask. Two problems on one R1: (1) count uni-valued subtrees (every node in the subtree equal). (2) search a target in a rotated sorted array.

Example. Tree: 5 with left 5 and right 5, left-left 5, left-right 4. Uni subtrees: each leaf, the right 5, not the whole tree. Rotated: [4,5,6,7,0,1,2] target 0 → index 4.

Dry run — walk this before you code.

StepWhat you holdResult / why
uni postorderleaf 4 is uni; sibling 5 is uni; parent 5 has mixed childrenCount leaves + the all-5 right child + …
rotated midl=0 r=6 mid=3 val=7. Left [4..7] is sorted. 0 is not in itSearch right half.
next midright half [0,1,2], find 0O(log n). Single-element-in-sorted is a different BS.

Say out loud. Two titles. Speak both. Rotated: one half is sorted — that is the invariant.

Source. LC 6461439 28 Jan 2025.

Clue → pattern. Two problems: tree all-equal subtrees (postorder flag); rotated search (BS + mid side).

Why this. Uni-valued: a subtree is uni if both children are uni and values match. Rotated: one half is sorted; decide which half holds the target.

Brute. Recompute subtree set each node; linear search rotated. Time O(n²) / O(n). Space O(n).

Optimal. O(n) tree; O(log n) rotated. Time O(n) / O(log n). Space O(h) / O(1).

// if a[l]<=a[mid] left sorted else right sorted

Two titles on one R1. Single element in sorted array (LC 6475219 R2) is a different rotated/xor BS.

Longest Repeating Character Replacement variation IE-asked

Question they ask. Longest substring you can make all-same by replacing at most k characters. Variation — lock if they meant something else.

Example. s = AABABBA, k=1. Window AABA length 4, maxFreq A=3, replacements 4−3=1 ≤ k. Answer 4.

Dry run — walk this before you code.

StepWhat you holdResult / why
expand rcounts, maxFreq = max count in windowValid while length − maxFreq ≤ k.
too many replacesmove l, decrement countsMaxFreq need not decrease for the standard proof.
answermax window length seenO(n) int[26]. Different Job ID — pattern only.

Say out loud. Not find-all-anagrams. Window + max frequency.

Source. Prince Medium 17 Oct 2025. Candidate linked LC 424. Job 3057703 — not 10454435.

Clue → pattern. Replace at most k to make a repeating window → window + max-freq.

Why this. Window is valid while (length − maxFreq) ≤ k. MaxFreq does not have to decrement on shrink for this problem (standard trick).

Brute. All windows. Time O(n²). Space O(1).

Optimal. O(n) window, int[26]. Time O(n). Space O(1).

while (r-l+1 - maxf > k) shrink;

Different Job ID. Pattern reuse only.

Count good-review words; sort reviews IE-asked

Question they ask. Given review strings and a set of “good” words, count good words per review and/or sort reviews by their rule. Ask the sort key.

Example. good = {good, great}. Reviews: “good product”, “ok”, “great and good”. Counts 1, 0, 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
setHashSet of good wordsO(1) lookup, not scan the good list per word.
tokenizesplit on space; maybe lower-case — ask punctuationCount hits.
sortAsk: by count desc? then original index?Do not invent the key. HashMap internals may follow.

Say out loud. Membership then sort. Speak the comparator they stated.

Source. LC 6570344 14 Mar 2025.

Clue → pattern. Words + a good-set → HashSet lookup; then sort by their rule.

Why this. Membership is O(1) average. Sorting is whatever comparator they stated — ask.

Brute. For each word scan the good list. Time O(n · G). Space O(1).

Optimal. HashSet of good words. Time O(n + sort). Space O(G).

if (good.contains(w)) cnt++;

Do not invent the sort key. HashMap internals were asked after a review-word-count in bible §5.F — be ready.

Min Arrows to Burst Balloons IE-asked

Question they ask. Balloons as intervals [start, end] on a number line. One arrow at x bursts every balloon covering x. Minimum arrows.

Example. [1,6], [2,8], [7,12], [10,16]. One arrow at 6 bursts the first two. One at 12 bursts the last two. Answer 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
sort by endends 6, 8, 12, 16Shoot at the earliest end.
arrow at 6bursts all with start ≤ 6[1,6] and [2,8] die.
next unburst [7,12]new arrow at 12[10,16] also dies. Count 2. Not merge-interval output.

Say out loud. Greedy on earliest end. Count groups, do not emit merged ranges.

Source. Deepak Jul 2026 with Islands.

Clue → pattern. Points on a line, shoot if overlap → sort by end, greedy.

Why this. Earliest-ending balloon must be shot; that arrow bursts all that cover that end.

Brute. Try all arrow x. Time O(n²). Space O(1).

Optimal. Sort by end O(n log n). Time O(n log n). Space O(1).

if (start > arrow) { arrows++; arrow=end; }

Not merge-intervals output — it is a count of non-overlappable groups.

Burning Tree IE-asked

Question they ask. Tree (usually binary). Fire starts at a target. Each minute it spreads to adjacent nodes. Minutes to burn all. Parent map may be banned.

Example. Same tree as Distance K: 1 with 2,3; 2 with 4,5. Start at 5. Minute 1: 2. Minute 2: 1 and 4. Minute 3: 3. Answer 3.

Dry run — walk this before you code.

StepWhat you holdResult / why
undirectedparent as DFS argument if they ban a MapSame setup as Distance K.
BFS layerslayer = one minuteAnswer is max distance, not the list of nodes at k.
leaf far side3 is farthestTime O(n).

Say out loud. BFS from target after you can walk to parent. Not Distance K’s “collect layer k.”

Source. GFG fresher 25 Jan 2025 R1 with Merge Intervals.

Clue → pattern. Minutes for fire from a target to all nodes → parent links + BFS.

Why this. Fire spreads to parent and children. Build parent map (or undirected adj) then multi-source is just BFS from target; time = max dist.

Brute. Simulate sets of burning nodes each minute naively. Time O(n²). Space O(n).

Optimal. BFS O(n). Time O(n). Space O(n).

// parent[u]=p; q.offer(target); max dist

If they ban parent map, pass parent as DFS arg then BFS — same as Distance K.

Race Car IE-asked

Question they ask. Start position 0 speed +1. Instruction A: pos += speed, speed *= 2. R: speed = −1 if speed>0 else +1 (and speed sign flip per their statement). Min instructions to reach target. Year-out remainder.

Example. target = 3. A → pos 1 speed 2. A → pos 3 speed 4. Two A’s. (Exact A/R table: use their statement.)

Dry run — walk this before you code.

StepWhat you holdResult / why
state(position, speed)Not DP on position alone — speed matters.
BFSeach A or R is an edgeFirst time you hit pos==target is min instructions.
bounddo not let |pos| explodePrune positions far past target.

Say out loud. BFS on state. Not UTA-default. Still the template if they name Race Car.

Source. GFG sde-1-34 ~2024 slug race-car. Reprint sde-1off-campus-2023.

Clue → pattern. Position + speed state, A/R instructions → BFS on state.

Why this. Not a 1D DP on position only — speed is part of the state. BFS min instructions.

Brute. All instruction strings. Time exponential. Space O(states).

Optimal. BFS (pos, speed). Time O(states). Space O(states).

// state key = pos+":"+speed; A: pos+=speed; speed*=2; R: speed = speed>0?-1:1

Year-out remainder, not UTA-default. Still a BFS-on-state template.

Search in Rotated Sorted Array; circular Kadane IE-asked

Question they ask. Two problems: search in rotated sorted array; maximum subarray sum on a circular array.

Example. Rotated: [4,5,6,7,0,1,2] target 0. Circular Kadane: [5, −3, 5] wrap 5+5=10 beats linear 5.

Dry run — walk this before you code.

StepWhat you holdResult / why
rotatedsame half-sorted BS as uni-rot cardO(log n).
linear kadanemax ending here5, then 5−3=2, then 2+5=7. Linear max 7.
min subarrayworst middle is −3total 7, wrap = total − min = 10. Guard: if all negative, wrap would be 0 — return the max element.
not robberHouse Robber circular forbids both ends as housesDifferent split.

Say out loud. Circular max = max(kadane, total − minSubarray) with the all-negative guard.

Source. LC 8014509 Apr 2026.

Clue → pattern. Rotated search = BS. Circular max subarray = max(kadane, total−minSubarray) with the all-negative guard.

Why this. Wrap max is total minus the worst middle segment, unless that would take nothing.

Brute. Rotate + linear; all wrap intervals. Time O(n²). Space O(1).

Optimal. O(n) kadane + min-kadane; O(log n) rotated search. Time O(n) / O(log n). Space O(1).

return Math.max(kadane, total - minKadane); // if not all negative

House Robber circular is a different split (cannot take both ends).

Group anagrams (small modifications) IE-asked

Question they ask. Group the strings that are anagrams of each other. Small modifications — ask if they want sorted groups or original order.

Example. [eat, tea, tan, ate, nat, bat] → groups {eat,tea,ate}, {tan,nat}, {bat}.

Dry run — walk this before you code.

StepWhat you holdResult / why
keysorted chars: aet, ant, abtOr int[26] frozen as a string.
mapkey → list of originalsOne pass.
not a windowwhole strings, not substrings of s vs pFind All Anagrams is the other card.

Say out loud. HashMap of canonical keys. O(n L log L) if you sort each string.

Source. Sachin LinkedIn LC 49 ~May 2026.

Clue → pattern. Group strings that are anagrams → map of sorted key or count-key.

Why this. Canonical key is sorted chars or int[26] frozen as a string.

Brute. Compare every pair. Time O(n² · L). Space O(nL).

Optimal. HashMap<String,List>. Time O(n L log L) sorted key. Space O(nL).

char[] c=s.toCharArray(); Arrays.sort(c); map.computeIfAbsent(new String(c), …)

Find-all-anagrams-in-a-string is a window, not grouping whole strings.

Longest Valid Parentheses; Median of Two Sorted Arrays IE-asked

Question they ask. Two heavy titles: longest valid parentheses substring; median of two sorted arrays (log time).

Example. Parens: ()(() longest valid is 2. Median: [1,3] and [2] → 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
parens stackindices of unmatched ‘(’ ; base −1When ‘)’ matches, length = i − new_top.
median ideacut array A and B so left has (n+m+1)/2 elementsNeed maxLeft ≤ minRight on both sides.
clockmedian-of-two burns time if you code before the invariantSpeak the cut first. Two titles — budget.

Say out loud. Parens O(n) stack or DP. Median O(log(n+m)) partition. Do not merge then pick middle unless n is tiny.

Source. LC 6606011 26 Mar 2025.

Clue → pattern. Longest valid () → stack of indices or DP. Median of two sorted → BS on partition (hard).

Why this. Valid parens: stack of last unmatched ‘(’ index; gap is length. Median: binary search the cut so left-max ≤ right-min.

Brute. All substrings check balance; merge arrays O(n+m). Time O(n²) / O(n+m). Space O(n).

Optimal. O(n) stack; O(log(n+m)) median BS. Time O(n) / O(log(n+m)). Space O(n) / O(1).

// stack push -1; on ) pop; if empty push i else ans=max(i-st.peek())

Two heavy titles in one R1. Median-of-two is easy to burn the clock — speak the partition invariant first.

Heaters; Max Width of Binary Tree IE-asked

Question they ask. Heaters: houses and heater positions; min radius so every house is covered. Max width of BT: max (rightmost−leftmost+1) index on any level.

Example. Houses [1,2,3,4], heaters [1,4]. Radius 1 covers (house 2 needs heater at 1, dist 1). Width: complete 3-level tree width 4 at the bottom.

Dry run — walk this before you code.

StepWhat you holdResult / why
heaters Rsort both; each house binary-searches nearest heaterR works iff every house has a heater within R. BS on R.
width BFSroot index 0, left 2*i+1, right 2*i+2 (or 1-based)width = last−first+1 on the level. Use long.
TUF 11Max Width also named live thereHeaters is the BS sibling on the AUTA post.

Say out loud. Heaters: monotone radius. Width: BFS indices, not node values.

Source. LC 7035289 AUTA ~2025.

Clue → pattern. Heaters: min radius to cover houses → BS on answer or two pointers on sorted. Width: BFS with column indices.

Why this. Radius R covers if every house has a heater within R — monotone. Width is last-first index on a level; use long for 2^height.

Brute. Try R; BFS without indices. Time O(R · n) / O(n). Space O(n).

Optimal. O(n log RANGE) heaters; O(n) width. Time see opt. Space O(n).

// width: q.offer({node, idx}); ans = max(ans, last-first+1)

TUF 11 also named Max Width live. Heaters is the BS sibling on the same AUTA post.

Trapping Rainwater; DP on Stocks IE-asked

Question they ask. Trap rain water on heights; and a stocks DP (buy/sell, maybe cooldown or 2 transactions — ask).

Example. Rain: [0,1,0,2,1,0,1,3,2,1,2,1] water 6. Stocks II (unlimited): prices [7,1,5,3,6,4] profit 7.

Dry run — walk this before you code.

StepWhat you holdResult / why
rain i=5 h=0leftMax 2, rightMax 3, water min(2,3)−0=2Precompute Lmax/Rmax or two pointers.
stocks unlimitedsum every uptick 1→5 and 3→6If at most 2 sells: states hold1, cash1, hold2, cash2.
OA-as-R1their later Maximal Rectangle is often our R2 analogueAsk k transactions vs unlimited.

Say out loud. Rain is min(Lmax,Rmax)−h. Stocks is state DP. Lock k.

Source. igreaper Nov 2025. OA-as-R1 first live.

Clue → pattern. Rain: Lmax/Rmax or stack. Stocks: state DP.

Why this. Water at i is min(leftMax,rightMax)−h[i]. Stocks: hold/cash transitions.

Brute. For each i scan left and right; recurse stock days. Time O(n²) / O(2^n). Space O(1) / O(n).

Optimal. O(n) two arrays or two pointers; O(n) stock states. Time O(n). Space O(n) or O(1).

water += Math.max(0, Math.min(l[i], r[i]) - h[i]);

OA-as-R1. Their later Maximal Rectangle is our R2 analogue on that write-up.

GetRandom O(1); sqrt to 8 decimals IE-asked

Question they ask. O(1) insert, delete, getRandom on a set of ints; and compute sqrt(x) to 8 decimals (no library if they forbid).

Example. Insert 1,2,3; delete 2; getRandom uniformly 1 or 3. sqrt(2) ≈ 1.41421356.

Dry run — walk this before you code.

StepWhat you holdResult / why
structureArrayList values + HashMap val→indexgetRandom = list.get(rand).
delete 2swap with last, pop, update mapThat is the O(1) trick.
sqrt BSlo=0 hi=x (or 1 if x<1); mid*mid ? xStop when hi−lo < 1e-9. Newton also fine. 8 decimals.

Say out loud. Map + compact array. Sqrt is real binary search or Newton. Not Job 10454435.

Source. LC 6573582 Feb 2025 BLR.

Clue → pattern. Insert/delete/getRandom O(1) → HashMap + ArrayList swap-delete. Sqrt: binary search reals or Newton.

Why this. Random index needs a compact array. Delete = swap with last. Sqrt: BS on double until precision.

Brute. List.contains O(n); Math.sqrt if they allow. Time O(n) / library. Space O(n).

Optimal. Map+list O(1); BS log PRECISION. Time O(1) / O(log P). Space O(n) / O(1).

int i=map.get(x); int last=arr.get(arr.size()-1); arr.set(i,last); map.put(last,i); arr.remove(arr.size()-1);

Reddit 1lqy9uq also GetRandom on R2. Two IEs, still not 10454435.

Zig-Zag BT; Largest BST in BT IE-asked

Question they ask. Zigzag (level-order, alternate reverse); and size of the largest BST subtree in a binary tree.

Example. Zigzag on 3 / 9,20 / 15,7 → [[3],[20,9],[15,7]]. Largest BST: a tree that is not a BST but a subtree of 3 nodes is.

Dry run — walk this before you code.

StepWhat you holdResult / why
zigzagBFS; odd levels reverse (or deque addFirst)O(n).
largest BST postorderreturn (isBST, min, max, size)Parent is BST iff both kids BST and max(left)<val<min(right).
update ansif isBST, ans = max(ans, size)Do not re-check inorder on every subtree (that is n²).

Say out loud. Zigzag is BFS. Largest BST is one postorder with bounds. Keys and Rooms was R2 on that IE.

Source. LC 6491881 Feb 2025.

Clue → pattern. Zigzag = BFS + reverse odd levels. Largest BST = postorder (min,max,size,isBST).

Why this. Level order with a deque (addFirst/addLast) or collect then reverse. BST check must return bounds so a parent can validate.

Brute. Inorder all subtrees. Time O(n²). Space O(n).

Optimal. O(n) both. Time O(n). Space O(n).

// Info dfs: if left.bst && right.bst && left.max < u.val < right.min

Keys and Rooms was R2 on the same IE.

Find Median from stream; max sum level in BT IE-asked

Question they ask. Running median of a stream; and the level of a binary tree with maximum node-sum (1-based level).

Example. Stream 1,2,3 → medians 1, 1.5, 2. Tree levels sums 1 | 2+3=5 | … return the level with max sum (tie: smallest level — ask).

Dry run — walk this before you code.

StepWhat you holdResult / why
two heapsmax-heap lo, min-heap hi; sizes differ by ≤1Median is peek or average.
level BFSqueue size = one level; long sumTrack best sum and its level.
same IE R2single-element sorted + LL sum-0Different cards.

Say out loud. Heaps for stream. BFS for level sum. long, not int.

Source. LC 6475219 Feb 2025 BLR.

Clue → pattern. Two heaps + BFS level sums.

Why this. Already covered median. Level sum is BFS; track max.

Brute. Sort stream; DFS levels with extra maps. Time O(n log n). Space O(n).

Optimal. Heaps + BFS. Time O(log n) / O(n). Space O(n).

// TUF 13 Maximum Level Sum is the same BFS family.

Same IE also had single-element-in-sorted and LL sum-0 nodes on R2.

Equal-split tree (remove one edge) IE-asked

Question they ask. Remove exactly one edge from a tree so the two sides have equal node-value sums (or equal counts — ask). Return yes/the edge.

Example. Values: root 1 with children 2 and 3; total 6. Subtree 3 equals 6/2. Cut the edge to 3.

Dry run — walk this before you code.

StepWhat you holdResult / why
totalDFS sum allIf odd, impossible for equal sums.
subtree 33 == total/2Cut that edge. One extra DFS or same DFS with a flag.
follow-uprecursion banned / spaceIterative stack. Why not BFS: you still need subtree sums, so postorder-ish.

Say out loud. One DFS returning subtree sums. Not a graph diameter.

Source. Naina UTA R2. Candidate said GFG.

Clue → pattern. Remove one edge, two equal node-sum halves → subtree sums.

Why this. If any subtree sum == total/2 (total even), you can cut that edge. One DFS.

Brute. Remove each edge, sum both sides. Time O(n²). Space O(n).

Optimal. One DFS returning subtree sum. Time O(n). Space O(h).

if (sub*2==total) found=true; return sub;

Follow-ups they wrote: why not BFS, recursion banned, space. Speak iterative stack if asked.

Row with max 1s in row-sorted 0/1 matrix IE-asked

Question they ask. m×n matrix, each row sorted 0s then 1s. Return the row with the most 1s (or its index). Ties: ask first vs last.

Example. Row0 0 0 1 1, row1 0 1 1 1, row2 0 0 0 1. Row 1 has three 1s.

Dry run — walk this before you code.

StepWhat you holdResult / why
start top-rightcol = n-1, row = 0Never move right.
see 1this row has ≥ (n−col) ones; record row; col−−Look for an even left-er 1.
see 0row++This row cannot beat the current col bound. O(m+n).

Say out loud. Staircase. Binary search per row is O(m log n) — mention then upgrade.

Source. IE.in 2024-grad AUTA mail R2.

Clue → pattern. Rows sorted 0 then 1 → staircase from top-right O(m+n).

Why this. Never move right. Left means this row has more ones; down tries the next row with the same column bound.

Brute. Count 1s per row O(mn) or BS per row O(m log n). Time O(mn). Space O(1).

Optimal. O(m+n) staircase. Time O(m+n). Space O(1).

int j=n; for i: while (j>0 && mat[i][j-1]==1) j--; track n-j

Search 2D Matrix II (TUF 21) is staircase for a target, same walk.

Bipartite students / enemies not same group IE-asked

Question they ask. Students (or nodes); enemy pairs cannot share a group. Can you split into two groups?

Example. Enemies (1-2),(2-3),(3-1). Triangle. Odd cycle → no.

Dry run — walk this before you code.

StepWhat you holdResult / why
edge = must differ2-color BFSColor 1 red, 2 blue, 3 needs red and blue.
odd cyclefailEach component colored on its own.
not topothis is bipartite, not course-schedule indegreeDSU only if you encode “same group” vs enemy carefully.

Say out loud. O(V+E) 2-color. Odd cycle is the no.

Source. LC 8362604 AUTA R2.

Clue → pattern. Enemy edges → 2-color BFS/DFS.

Why this. Odd cycle ⇒ impossible. Each component colored independently.

Brute. 2^n assignments. Time O(2^n). Space O(n).

Optimal. O(V+E) color. Time O(V+E). Space O(V).

if (col[v]==-1) col[v]=col[u]^1; else if (col[v]==col[u]) return false;

Not topo. Not DSU unless you DSU “must-same” and check enemy pairs.

Rotate Image 90° IE-asked

Question they ask. Rotate an n×n matrix 90° clockwise in place.

Example. [[1,2,3],[4,5,6],[7,8,9]] → [[7,4,1],[8,5,2],[9,6,3]].

Dry run — walk this before you code.

StepWhat you holdResult / why
transposeswap (i,j) with (j,i)[[1,4,7],[2,5,8],[3,6,9]].
reverse each row7 4 1 / 8 5 2 / 9 6 3That is 90° clockwise.
anti-clockwisetranspose then reverse columns, or reverse rows then transposeAsk the direction.

Say out loud. Transpose + reverse rows. Extra matrix is the brute they want named.

Source. LC 6806195 AUTA R2 with Next Perm similar.

Clue → pattern. In-place 90 clockwise → transpose then reverse each row.

Why this. (i,j) → (j, n-1-i). Transpose is (i,j)↔(j,i); reverse row finishes it.

Brute. Extra matrix. Time O(n²). Space O(n²).

Optimal. In-place O(n²) time O(1) extra. Time O(n²). Space O(1).

swap m[i][j], m[j][i]; then reverse row

Anti-clockwise is transpose + reverse columns. Ask.

Longest subarray sum = 0 IE-asked

Question they ask. Longest subarray whose sum is 0 (negatives allowed).

Example. [15, −2, 2, −8, 1, 7, 10, 23]. Subarray −2,2,−8,1,7 sums to 0, length 5.

Dry run — walk this before you code.

StepWhat you holdResult / why
prefix15, 13, 15, 7, 8, 15, 25, 48prefix 15 repeats at i=0, i=2, i=5.
first index of 15store 0 at prefix 15Later 15 at i=5 → length 5. Keep the earliest index.
sum 0 from startif prefix==0, length i+1Put prefix 0 at index −1.

Say out loud. HashMap prefix → first index. Count of zero-sum subarrays is a different map (counts, not first).

Source. LC 7850431 snippet R2.

Clue → pattern. Exact sum 0 → prefix + first-index HashMap.

Why this. prefix[j]−prefix[i]=0 ⇒ same prefix. Store first occurrence to maximize j−i.

Brute. All L,R. Time O(n²). Space O(1).

Optimal. O(n) map. Time O(n). Space O(n).

if (!map.containsKey(sum)) map.put(sum,i); else ans=max(i-map.get(sum));

Count of zero-sum subarrays stores counts, not first index.

Aggressive Cows IE-asked

Question they ask. n stalls on a line, place k cows, maximize the minimum distance between cows.

Example. Stalls [1,2,4,8,9], k=3. Best min-distance 3 (places 1,4,8 or 1,4,9).

Dry run — walk this before you code.

StepWhat you holdResult / why
sortalready sortedNeed sorted positions.
T=3 feasibleplace 1, skip 2, place 4, place 83 cows. Try 4.
T=41, then 8, no thirdAnswer 3. Same family as power-minmax on that loop.

Say out loud. BS on distance + greedy place. Snippet.

Source. LC 7724048 snippet R2.

Clue → pattern. Maximize min distance → BS on answer + greedy place.

Why this. Chapter 25 maximize-minimum.

Brute. Try every distance. Time O(MAX · n). Space O(1).

Optimal. Sort stalls + O(n log RANGE). Time O(n log n + n log RANGE). Space O(1).

// feasible(d): place k cows with gap >= d

Snippet. Same family as power allocation on that loop’s R1.

Clone Graph; Next Palindromic Number IE-asked

Question they ask. Clone a graph (cycles, Node.neighbors); and next palindromic number after n (as digits).

Example. Graph 1—2—3—1 triangle: clone must not loop forever. Next palindrome after 129 → 131.

Dry run — walk this before you code.

StepWhat you holdResult / why
cloneMap old→new; create node then walk neighborsMap before recurse or you infinite-loop.
palindromemirror left half onto right: 129 → 121 too smallIncrement the left half: 13 mirrored 131.
all 9s99 → 101Carry. Not next permutation.

Say out loud. Clone is DFS/BFS + map. Palindrome is digit mirror + increment. Two titles.

Source. LC 7280347 28 Aug 2025.

Clue → pattern. Clone: map old→new + DFS. Next palindrome: mirror left half, increment if needed.

Why this. Graph clone must map before walking neighbors (cycles). Palindrome: mirroring is O(digits); handle 9s carry.

Brute. No map infinite loop; increment n until palindrome O(n · digits). Time infinite / O(gap · D). Space O(V).

Optimal. O(V+E) clone; O(D) palindrome. Time O(V+E) / O(D). Space O(V) / O(D).

if (map.containsKey(u)) return map.get(u); Node n=new Node(u.val); map.put(u,n);

Two titles. Next palindrome is not next permutation.

Falling Path Sum variation; Rotten variation IE-asked

Question they ask. Falling path (down / diag-down, min or max sum) and a Rotten Oranges variation. Prince later wrote a right/diag matrix that is not identical — lock moves.

Example. 3×3 grid falling min: from each cell go down, down-left, down-right. Rotten: multi-source BFS minutes.

Dry run — walk this before you code.

StepWhat you holdResult / why
falling DPdp[r][c] = a[r][c] + min of allowed parentsO(mn). DFS without memo is exponential.
rottenqueue all 2s at minute 0See rotten card in §1.
PrinceJob 3057703 right/diag — different dirsDo not stamp LC 931.

Say out loud. DP on the DAG they drew. Rotten is BFS. Confirm directions.

Source. LC 6461439 28 Jan 2025 R2.

Clue → pattern. Grid down/diag max/min → DP. Rotten = multi-source BFS.

Why this. Prince’s later matrix (Job 3057703) is right/diag-up/diag-down to a fixed end — not identical. Speak the move set they drew.

Brute. All paths / rescan minutes. Time exp / O((mn)²). Space O(mn).

Optimal. DP O(mn); BFS O(mn). Time O(mn). Space O(mn).

// dp[c] = a[r][c] + min(dp3 from prev row)

Not identical to LC 931 unless they said so.

LL → height-balanced BST; First Missing Positive IE-asked

Question they ask. Convert a sorted linked list to a height-balanced BST; and first missing positive in an unsorted int array (O(n) time, O(1) extra if they insist).

Example. LL 1→2→3→4→5 → BST rooted at 3. Array [3,4,−1,1] first missing positive 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
BST midcount n or slow-fast mid; left half / right half recurseMid as root keeps height log n.
FMP cycleswap 3 to index 2, 4 to index 3, 1 to index 0Then scan: index 1 is not 2.
ignorenegatives, zeros, >nThey do not sit in the 1..n permutation.

Say out loud. Sorted LL → pick mid. FMP → cyclic sort. HashSet is the extra-space brute.

Source. Deepak Jul 2026.

Clue → pattern. Sorted LL to BST → mid split. First missing positive → cyclic sort 1..n.

Why this. Balanced BST from sorted sequence is always pick mid as root. Missing positive in O(1) extra: swap each a[i] to index a[i]−1 if in 1..n.

Brute. Insert sequentially (skew); HashSet positives. Time O(n log n) / O(n). Space O(n).

Optimal. Array mid O(n); cyclic sort O(n) time O(1) extra. Time O(n). Space O(n) array / O(1).

while (a[i]>=1 && a[i]<=n && a[a[i]-1]!=a[i]) swap;

Cyclic sort follow-up also appeared on Prem’s OA-as-R1 R2.

Dijkstra with PQ IE-asked

Question they ask. Non-negative weighted shortest path from src. They said Dijkstra with a priority queue.

Example. 0→1 weight 2, 0→2 weight 5, 1→2 weight 1. dist[2] should be 3, not 5.

Dry run — walk this before you code.

StepWhat you holdResult / why
PQpush (0, src). pop min distBFS would treat edges as 1 — wrong.
relax 1→23 < 5, push (3,2)Java PQ has no decrease-key: push again, skip stale if d != dist[u].
not K-stopsplain Dijkstra can use many hopsCheapest-within-K is a different card.

Say out loud. O((V+E) log V). Skip stale pairs. Non-negative weights only.

Source. Sachin ~May 2026 R2 with House Robber II.

Clue → pattern. Non-neg weighted shortest → PQ, skip stale.

Why this. BFS is wrong on weights. Decrease-key is not in Java PQ — push new (dist,node), ignore stale if d!=dist[u].

Brute. Bellman O(VE) or DFS all paths. Time O(VE). Space O(V).

Optimal. O((V+E) log V). Time O((V+E) log V). Space O(V).

if (d != dist[u]) continue; // stale

Cheapest-within-K-stops is not plain Dijkstra.

Keys and Rooms IE-asked

Question they ask. rooms[i] is a list of keys. Start in room 0. Can you visit every room?

Example. rooms = [[1],[2],[3],[]] → yes. [[1,3],[3,0,1],[2],[0]] → room 2 never reached? Keys in 2 are stuck — cannot enter 2. False.

Dry run — walk this before you code.

StepWhat you holdResult / why
start 0BFS/DFS with a visited setKeys you hold = rooms you can enter.
visited size== n ?Directed graph reachability.
not islandsnot a grid floodStart is only room 0.

Say out loud. O(n + keys). If visited < n, false.

Source. LC 6491881 R2.

Clue → pattern. Rooms[i] = keys → DFS/BFS from 0, visited == n.

Why this. Reachability on a directed graph. Start at 0 only.

Brute. Perms of rooms. Time O(n!). Space O(n).

Optimal. O(n + keys). Time O(V+E). Space O(n).

dfs(0); return visCount==n;

Not Number of Islands (undirected grid).

Single element in sorted array; remove consecutive LL nodes sum 0 IE-asked

Question they ask. Two problems: the single non-duplicate in a sorted array of pairs; delete consecutive linked-list nodes that sum to 0.

Example. Array [1,1,2,3,3,4,4,8,8] unique 2. LL 1→2→−3→3→1 after removing 1+2+(−3)=0 becomes 3→1 (or further if they chain).

Dry run — walk this before you code.

StepWhat you holdResult / why
pairs BSeven index should equal i+1; if not, unique is on the left (including mid)O(log n). XOR is O(n) — mention it.
LL dummyprefix sum map: 0→dummyWhen prefix repeats, skip from old node.next to current.next.
recomputeafter a delete, prefixes after that point change — standard solution remaps from dummyWalk once with care, or two-pass.

Say out loud. Do not mix with first missing positive. Two separate codes.

Source. LC 6475219 R2.

Clue → pattern. All pairs but one unique, sorted → XOR or BS on even/odd index. LL: prefix map of sum → last node, delete the middle.

Why this. Unique element: in pairs, even index should equal next; BS the mismatch. Sum-0 consecutive: dummy + HashMap prefix→node; when prefix repeats, relink.

Brute. Linear XOR still O(n) — OK; they may want log n. LL: nested. Time O(n) / O(n²). Space O(1) / O(n).

Optimal. O(log n) BS; O(n) prefix map on LL. Time O(log n) / O(n). Space O(1) / O(n).

// if prefix seen: dummy-to-that-node.next = cur.next; wipe map range

Two problems. Do not mix with first missing positive.

Word Ladder; Count Beautiful Splits IE-asked

Question they ask. Word Ladder (shortest transformation length) and Count Beautiful Splits. Beauty definition was not fully specified — ask before coding splits.

Example. hit → cog with dict hot,dot,dog,lot,log,cog. Length 5. Beautiful splits: lock their predicate (e.g. both halves palindrome — that is a different LC; do not assume).

Dry run — walk this before you code.

StepWhat you holdResult / why
ladder BFSqueue words, 26 letter tries, remove from set when queuedLength = steps + 1 depending on counting begin.
II vs II is length; II is all shortest paths (parents per layer)This card is I plus an unnamed beauty.
beautyask the definition; if unnamed, stay unnamedNo extra LC id.

Say out loud. Ladder is BFS on the word graph. Splits wait for their rule.

Source. LC 7035289 AUTA. TUF 06 Word Ladder II + Beautiful Splits.

Clue → pattern. Ladder = BFS words. Beautiful splits: title named — clarify the beauty definition; no extra LC id unless they linked one.

Why this. Ladder: 26-letter edges, remove from dict when queued. II asks all shortest paths — keep parents per layer.

Brute. All word sequences; all split indices. Time exp / O(n² · check). Space O(dict).

Optimal. BFS O(N · L · 26). Splits: only after they define beauty. Time O(N L 26). Space O(N).

for each pos 26 letters; if dict.remove(nxt) q.offer

Beautiful splits stay unnamed on mechanism if the body did not define it.

Stone Collision; reconstruct coins from ways-DP IE-asked

Question they ask. Stone collision (asteroid-like signed stones) and reconstruct a coin combination from a ways-DP they already wrote. Do not invent the coin recurrence.

Example. Stones [5,10,−5] → [5,10] if 10 > 5 and signs oppose? Standard asteroid: same as §1 asteroid card. Coins: walk their dp table backwards from dp[amount].

Dry run — walk this before you code.

StepWhat you holdResult / why
collisionstack; opposite signs fight absSame as asteroid. Resimulate is brute.
coins reconstructif dp[x] came from dp[x−c], append coin cOnly using their recurrence. §5.B: do not guess beyond the phrases.
two problemsfinish collision first, then ask the DP formula againUnnamed extras stay unnamed.

Say out loud. Collision is the stack. Coins reconstruction follows their DP, not a guessed LC.

Source. LC 6606011 R2. Beyond those phrases in §5.B unnamed.

Clue → pattern. Collision = asteroid-like stack. Coins: they had a ways-DP and asked reconstruct — stay with their recurrence.

Why this. Do not invent the coin recurrence. Stone collision is the asteroid stack unless they defined a different rule.

Brute. Resimulate / enumerate coin sequences. Time O(n²) / exp. Space O(n).

Optimal. Stack / reconstruct from DP parents. Time O(n) / O(nT). Space O(n).

// unnamed coins: ask the transition; do not stamp LC 518 as exact

§5.B says do not guess beyond the phrases.

LFU Cache + extensible-cache LLD IE-asked

Question they ask. LFU cache: get/put O(1), evict least-frequent, tie → LRU inside that frequency. They also said extensible cache (Strategy for eviction). TUF 15 URL vs body may say LRU vs LFU — speak the conflict.

Example. cap=2. put 1, put 2, get 1 (freq 1 is now 2), put 3. Evict 2 (freq 1) not 1.

Dry run — walk this before you code.

StepWhat you holdResult / why
mapskey→node; freq→DLL of keys; minFreqBump: unlink from freq f, insert into f+1, maybe minFreq++.
evicthead of minFreq listThat list is LRU order inside the bucket.
Strategyinterface EvictionPolicy { victim() }Extensible LLD. Not Login Tracker.

Say out loud. LFU is not LRU. Say which they want. O(1) needs freq buckets.

Source. Reddit 1idtlan 22 Nov 2024.

Clue → pattern. LFU: HashMap key→node, freq→DLL, minFreq. Extensible: Strategy for eviction.

Why this. Need O(1) bump freq and evict min-freq LRU-inside-bucket. LRU is not enough.

Brute. Scan all keys for min freq. Time O(n). Space O(n).

Optimal. O(1) bucket maps. Time O(1). Space O(capacity).

// node.freq++; move to freq+1 list; if old list empty minFreq++

TUF 15 URL vs body LFU/LRU conflict — say it. Not Login Tracker.

Kadane water-level-change; in-place freq 1..N IE-asked

Question they ask. A Kadane-shaped “water level change” (ask the exact formula) and in-place frequencies of values in 1..N.

Example. Freq: a = [2,3,3,2,5], n=5. After encoding, counts of 1..5. Water: if they give deltas, max subarray of deltas is Kadane.

Dry run — walk this before you code.

StepWhat you holdResult / why
freq encodefor each a[i], add n to a[(a[i]%n)−1]Count of v is a[v−1]/n. Needs values already in 1..n.
waterask: is water[i] a height or a delta?If max rise over a contiguous spell → Kadane. Described, not an LC stamp.
spacethey insisted O(1) extraThe ±n trick. HashMap is the brute.

Say out loud. Ask the water formula. 1..N freq without a second array is the encoding.

Source. Prabhash May 2025 R2.

Clue → pattern. Max water from a delta array → Kadane-like. Freq 1..N in-place → ±n encoding or swap.

Why this. Ask the water formula. 1..N freq without extra array: add n to a[a[i]%n] then decode counts as /n.

Brute. Prefix extras. Time O(n). Space O(n).

Optimal. O(n) time O(1) extra if they insisted in-place. Time O(n). Space O(1).

a[v] += n; count(i) = a[i]/n;

Described, not an LC stamp.

Cyclic sort similar to First Missing Positive; graph BFS/DFS IE-asked

Question they ask. Cyclic sort similar to first missing positive, then an unnamed graph BFS/DFS. OA-as-R1. Graph stays unnamed.

Example. Array [3,1,2,4] cyclic sort → [1,2,3,4]. Graph: do not invent the prompt.

Dry run — walk this before you code.

StepWhat you holdResult / why
swapwhile a[i] in 1..n and a[a[i]−1]!=a[i], swapSame as FMP without the missing scan if they only wanted sort.
graphunnamed — ch.25 if they only said BFSTheir later “R3” is not automatically your R3.
OA-as-R1do not forecast 10454435Two patterns, one unnamed.

Say out loud. Cyclic sort in-place. Unnamed graph: stay unnamed.

Source. Prem LinkedIn OA-as-R1 ~Oct 2025.

Clue → pattern. Put values at index+1; then a graph traversal they did not name.

Why this. Cyclic sort family already in Deepak card. Unnamed graph stays unnamed.

Brute. HashSet. Time O(n). Space O(n).

Optimal. In-place swaps. Time O(n). Space O(1).

while (a[i] in 1..n && a[a[i]-1]!=a[i]) swap;

OA-as-R1. Their “R3” is not automatically your R3.

Array two-pointer; DP on triangular matrices IE-asked

Question they ask. An array two-pointer problem (unnamed exact) and DP on a triangular matrix (path sum). OA-as-R1. Titles unnamed beyond the phrases.

Example. Triangle [[2],[3,4],[6,5,7],[4,1,8,3]] min path 2+3+5+1=11. Two-pointer: e.g. sorted pair-sum — lock their array.

Dry run — walk this before you code.

StepWhat you holdResult / why
triangle bottom-uprow i from n-2: a[i][j] += min(below, below-right)O(n²). All paths is exponential.
two-pointersort first unless already sorted; l/r until they name the goalDo not invent 3-sum.
OA-as-R1pattern names onlyStay unnamed on the array problem.

Say out loud. Triangle is bottom-up DP. Two-pointer after they name the invariant.

Source. Vaishali ~Mar 2026 OA-as-R1.

Clue → pattern. Two-pointer on sorted / opposite ends. Triangle DP is path-sum from the bottom.

Why this. Triangle: dp[r][c] = val + min(below, below-right). Two-pointer: name the sort invariant.

Brute. Nested / all paths. Time O(n²) / exp. Space O(n²).

Optimal. O(n) two-pointer; O(n²) triangle or rolling. Time O(n) / O(n²). Space O(1) / O(n).

// triangle: for r=n-2..0 dp[c]=a[r][c]+min(dp[c],dp[c+1])

Titles unnamed beyond those phrases. OA-as-R1.

Remove K Digits; Split Array Largest Sum IE-asked

Question they ask. Split array into m non-empty contiguous parts; minimize the largest part-sum. (Remove K Digits is already §1 — this card is the split.) Phone OA-as-R1.

Example. [7,2,5,10,8], m=2. Split after 7+2+5=14 vs 10+8=18 → max 18; better 7+2=9 vs 5+10+8=23 worse; 7+2+5+10=24 vs 8. Best max is 18.

Dry run — walk this before you code.

StepWhat you holdResult / why
lo, hilo = max element 10, hi = total 32Monotone in the cap M.
M=18greedy pack: 7+2+5=14, then 10+8=18. Two pieces≤ m. Try smaller.
Remove Kalready a §1 card — do not re-code it here unless they ask bothPhone OA-as-R1.

Say out loud. Minimize-maximum: BS on the cap + greedy pack. DP O(n² m) is the brute.

Source. LC 6630775 Apr 2025 phone. OA-as-R1 flag on bible row.

Clue → pattern. Split array into m parts, minimize the max part → BS on answer.

Why this. Chapter 25 minimize-maximum. feasible(M) = can we cut into ≤ m pieces each sum ≤ M.

Brute. DP O(n² m). Time O(n² m). Space O(n m).

Optimal. BS + greedy pack O(n log SUM). Time O(n log SUM). Space O(1).

// same lo/hi as ship packages; feasible counts pieces

Phone OA-as-R1. Remove K Digits already in section A.

Validate Sum Tree; Minimum Knight Moves IE-asked

Question they ask. Validate a sum tree (every node equals left-subtree-sum + right-subtree-sum; leaves 0 or themselves — lock). Knight moves already in §1.

Example. Node 10 with 4 and 6, 4 has 1 and 3. 1+3=4, 4+6=10. Valid. Knight: see §1 knight card — one rehearsal.

Dry run — walk this before you code.

StepWhat you holdResult / why
postorderreturn subtree sum; boolean okIf node is leaf, sum = val (or 0 — ask).
checkval == leftSum + rightSumResumming from scratch each node is n².
knightBFS on infinite chessboard, pruneDo not recode twice in one hour.

Say out loud. One postorder. Knight is BFS. Same loop may ask both.

Source. LC 6629948 Apr 2025.

Clue → pattern. Sum tree: node = left-sum+right-sum (or 0 leaf). Knight: BFS.

Why this. Postorder return subtree sum and a boolean. Knight card already in A.

Brute. Resum each subtree from scratch. Time O(n²). Space O(h).

Optimal. One postorder O(n). Time O(n). Space O(h).

int[] dfs: {sum, ok}; ok = leaf || (val==Lsum+Rsum && L.ok && R.ok)

Knight already linked in A — one rehearsal.

Delivery stations / parcels + classes + topological sort IE-asked

Question they ask. Delivery stations / parcels as classes, plus a topological order of jobs. Not LC 210 Course Schedule. Not LC 962. Sibling on that post is max-sum switching lists.

Example. Station A must finish before B, B before C. Classes: Parcel, Station, Graph. Order A,B,C.

Dry run — walk this before you code.

StepWhat you holdResult / why
OODParcel id; Station id; Edge prereqSpeak fields first.
Kahnindegree 0 queueIf leftover nodes, cycle — ask if cycles possible.
not 210do not stamp Course ScheduleNot LC 962. Max-sum LL is the other problem.

Say out loud. Types then Kahn. Do not open LC 210 as the answer id.

Source. LC 6369243. First-hand wording.

Clue → pattern. Entities + prereq order → OOD types then Kahn. Not LC 210.

Why this. They asked classes and a topo of jobs/stations. Design Station/Parcel/Graph, then indegree.

Brute. Manual order. Time —. Space —.

Optimal. Kahn on the job graph. Time O(V+E). Space O(V+E).

// class Station, Parcel; Graph.kahn()

NOT LC 962. NOT Course Schedule 210. Sibling problem on that post is max-sum switching LLs.

Validate sudoku (not Solver) IE-asked

Question they ask. Validate a filled or partial 9×9 sudoku (rows, cols, 3×3 boxes). They said validate, not solve.

Example. A board with two 5s in row 0 is invalid. Empty cells skip.

Dry run — walk this before you code.

StepWhat you holdResult / why
9+9+9 setsor boolean[9][9] for row/col/boxBox index = (r/3)*3 + c/3.
81 cellsO(1) sizeSolver is backtracking — year-out dump has Solver separately.
partialskip ‘.’ Ask the empty char.

Say out loud. Validation only. Do not start a solver.

Source. GFG sde-1-17 their later live.

Clue → pattern. Check 9 rows, 9 cols, 9 boxes → sets.

Why this. Validation is O(1) cells (81). Solver is backtracking — they said validate.

Brute. Same 81 checks. Time O(1). Space O(1).

Optimal. boolean[9] or HashSet per unit. Time O(1). Space O(1).

int b = (r/3)*3 + c/3; if seen row/col/box return false;

Pre-2024 dump also has Sudoku Solver — different, year-out.

Word Ladder family CAT→MEN IE-asked

Question they ask. Word Ladder with begin CAT and end MEN (year-out adjacent). Same BFS as Word Ladder I.

Example. CAT → CAT with one letter? Use their dictionary. Length is BFS layers.

Dry run — walk this before you code.

StepWhat you holdResult / why
set dictremove when queued so you do not revisit26 letters × word length.
end foundreturn stepsI not II.
year-outpattern reuse, not UTA-defaultSame family as §1 / TUF ladder.

Say out loud. BFS. Do not DFS the dictionary first.

Source. GFG sde-1-17 R4/BR-adjacent.

Clue → pattern. Same BFS as Word Ladder. Begin/end given as CAT/MEN.

Why this. Unweighted transformations. Dictionary membership.

Brute. All sequences. Time exp. Space O(dict).

Optimal. BFS. Time O(N L 26). Space O(N).

// same as Word Ladder card

Year-out adjacent. Pattern reuse. Same BFS family as Word Ladder above.

Sum of a very long string IE-asked

Question they ask. Add two numbers given as strings (too long for long). Schoolbook add from the right. Not the 1226# encoded parser. Sibling: k-page visits.

Example. 999 + 1 → 1000.

Dry run — walk this before you code.

StepWhat you holdResult / why
i,j from endsdigit + digit + carrysb.append(s%10); carry s/10.
reverse at endor append then reverseDo not Integer.parseInt.
BigIntegerhonest to mention; they often want the loopNot encoded 1226#.

Say out loud. O(L) digit add. AUTA. k-page is the sibling IE problem.

Source. Nisarg AUTA R1 with k-page visit sequence.

Clue → pattern. Add digit-strings that do not fit in long → schoolbook add from the right, StringBuilder.

Why this. BigInteger is honest to mention; they often want digit loops. Do not parse as int. Encoded-frequency is a different parser.

Brute. Reverse to int arrays, add with carry. Time O(L). Space O(L).

Optimal. Two indices i,j; carry; sb.append. Time O(L). Space O(L). Linear vs trying all alignments.

int i = a.length()-1, j = b.length()-1, c = 0; StringBuilder sb = new StringBuilder();
while (i >= 0 || j >= 0 || c > 0) {
  int s = c + (i>=0 ? a.charAt(i--) - '0' : 0) + (j>=0 ? b.charAt(j--) - '0' : 0);
  sb.append(s % 10); c = s / 10;
}
return sb.reverse().toString();

AUTA. Not encoded 1226#. k-page sequence is the sibling on the same IE.

k-page visit sequence IE-asked

Question they ask. A sequence of page ids; something about k consecutive visits (unique k-gram, count, last-k — title named, extra constraints unnamed). Clarify IO. Not loyal-customers-two-days.

Example. pages [1,2,1,3], k=2. Windows (1,2), (2,1), (1,3). If they want unique pages in the window, counts differ.

Dry run — walk this before you code.

StepWhat you holdResult / why
askcount unique k-windows? reconstruct? last k pages?Unnamed details.
structureDeque of k + HashMap countsSlide: add last, drop first, update map.
not loyalloyal-customers is two-day logsDo not paste that solution.

Say out loud. Window of k + map. Lock the output before coding.

Source. Nisarg AUTA R1. Title named; extra constraints unnamed — lock IO.

Clue → pattern. Sequences of k page visits (unique consecutive k, count, or reconstruct — clarify) → sliding window of k + HashMap.

Why this. Exact prompt unnamed beyond the title. Typical: last-k pages or unique k-grams. Do not invent loyal-customers-two-days.

Brute. All windows of k, copy into a set. Independent windows. Time O(n·k). Space O(k).

Optimal. Deque + Map of counts in the window. Time O(n). Space O(k). Linear vs per-window copies.

Deque<Integer> w = new ArrayDeque<>(); Map<Integer,Integer> f = new HashMap<>();
for (int p : pages) {
  w.addLast(p); f.merge(p, 1, Integer::sum);
  if (w.size() > k) { int x = w.removeFirst(); if (f.merge(x,-1,Integer::sum)==0) f.remove(x); }
}

Title named, details unnamed. Clarify. Not loyal-customer logs paste.

Matrix max-path right/diag (Prince) IE-asked

Question they ask. Max path in a matrix moving right and diagonal (Prince Job 3057703). He wrote it is not identical to Falling Path. Lock which diagonals. Not Job 10454435.

Example. After they name dirs, e.g. right / right-up / right-down. Small grid [[1,2],[3,4]]: start left column, end right — ask start cells.

Dry run — walk this before you code.

StepWhat you holdResult / why
lock dirsdraw the three arrowsFalling Path is down/diag-down from the top row — different.
DPdp[r][c] = a[r][c] + max of allowed predecessorsO(mn). DFS all paths is exponential.
Unique Pathsthat is a count, right/down onlyThis is a max. No LC id.

Say out loud. Confirm moves, then DP. Do not call it Falling Path.

Source. Prince Job 3057703 R2. Not identical to Falling Path. Not Job 10454435. LC 424 was Prince R1.

Clue → pattern. Max path moving right and diagonal (lock which diags) → DP from the left.

Why this. Prince wrote it is not identical to Falling Path. Unique Paths is right/down count, not max. Do not reuse falling-path down/diag-down until they confirm dirs.

Brute. DFS all allowed moves. All paths. Exponential. Space O(mn) stack.

Optimal. dp[r][c] = a[r][c] + max of allowed predecessors. Time O(mn). Space O(mn) or O(m). DP vs all paths.

// after they name dirs, example right / right-up / right-down:
// dp[r][c] = a[r][c] + max(left, up-diag, down-diag)
// confirm before typing — this is not Falling Path

Job 3057703. Do not call it Falling Path. Do not stamp an LC id.

3. TUF popular-companies — named or described live, not already a §1/§2 card

Opened bodies in old experiences/takeyouforwardexperiences/. SDE II/L5 were not copied. 07 and 09 are the same write-up (Koko + Min Stack) counted once.

Maximum Size Subarray Sum Equals k IE-asked

Question they ask. Longest subarray with sum exactly k (negatives possible → prefix map). TUF 01 live R3 and R5.

Example. [1, −1, 5, −2, 3], k=3. One answer length 4 (1,−1,5,−2) or 2 (5,−2) — longest 4.

Dry run — walk this before you code.

StepWhat you holdResult / why
prefix1, 0, 5, 3, 6need = prefix − k. prefix 3 at i=3, need 0 which was at i=1 → length 2; also prefix 3 with need 0 from −1…
first indexstore earliest prefix to maximize lengthIf all non-negative, a window also works — verify signs.
sliding-window wordingthey may still have negativesAsk. Do not assume two pointers.

Say out loud. Prefix + first-index map. Same as sum=0 with need prefix−k.

Source. TUF 01 live R3 and again R5.

Clue → pattern. Longest subarray with sum k → prefix + first-index map.

Why this. Same as sum=0 but need = prefix−k. Window only if all non-negative.

Brute. O(n²) pairs. Time O(n²). Space O(1).

Optimal. O(n) HashMap. Time O(n). Space O(n).

need=sum-k; if (map.containsKey(need)) ans=max(i-map.get(need));

They used a sliding-window wording on the second ask — still verify signs.

Decode Ways ii IE-asked

Question they ask. Decode Ways with ‘*’ wildcards (1–9 or 10–26 cases). Number of ways, not the 1226# frequency parser. No LC id on the TUF page.

Example. s = 1*. ‘1’ then ‘*’ as 1–9 → 9 ways for the pair 11–19 plus ‘1’ and ‘*’ as two digits… lock the classic table: 1* has 18 ways on LC 639 — if they did not link it, compute from their rules.

Dry run — walk this before you code.

StepWhat you holdResult / why
dp[i]ways to decode s[:i]One-digit ways + two-digit ways.
*9 one-digit; two-digit depends on previous 1 or 2Casework. Rolling O(1) space.
not 1226#that parser counts letters, not waysDo not invent an LC id.

Say out loud. O(n) DP with * cases. Recurse splits is exponential.

Source. TUF 02 live R2. No URL on the page.

Clue → pattern. Number of ways to decode, ‘*’ wildcard → DP with 9/15 cases.

Why this. dp[i] depends on one-digit and two-digit decodes. * is 1–9 or 10–26 cases. Not the encoded-frequency parser.

Brute. Recurse splits. Time exp. Space O(n).

Optimal. O(n) DP, careful * cases. Time O(n). Space O(1) rolling.

// dp[i] += ways1(s[i-1]) + ways2(s[i-2..i-1])

No LC id on the TUF page. Do not invent one. Different from 1226#24#(2).

House Robber (linear) IE-asked

Question they ask. House Robber on a line: max money, cannot rob adjacent houses. Be ready for circular.

Example. [2,7,9,3,1] → 2+9+1=12 or 7+3=10 or 7+1=8 → 12.

Dry run — walk this before you code.

StepWhat you holdResult / why
i=0prev2=0 prev1=2Take 2.
i=1max(2, 0+7)=7Take 7.
i=2max(7, 2+9)=11Then 11 vs 7+3=10 → 11; then 11 vs 11+1=12.
circularmax(rob[0..n-2], rob[1..n-1])Do not jump to House Robber III (tree).

Say out loud. O(n) two variables. Linear first.

Source. TUF 02 live R3.

Clue → pattern. Linear adjacent DP — then be ready for circular (bible).

Why this. Same robLine as section A.

Brute. 2^n. Time O(2^n). Space O(n).

Optimal. O(n) two vars. Time O(n). Space O(1).

cur = max(cur, prev + a[i]);

If they then say circular, split. Do not jump to III.

Longest Consecutive Sequence IE-asked

Question they ask. Longest consecutive sequence of integers (values, not indices). Unsorted array.

Example. [100,4,200,1,3,2] → 1,2,3,4 length 4.

Dry run — walk this before you code.

StepWhat you holdResult / why
set100,4,200,1,3,2Start a run only if x−1 not in set.
x=11,2,3,4 then stopLength 4. 2,3,4 are not starts.
not a windowarray order is irrelevantSort is O(n log n) brute-ish; HashSet O(n) average.

Say out loud. Expand from sequence starts. Not LIS, not a sliding window on indices.

Source. TUF 02 live R5.

Clue → pattern. Longest run of consecutive ints → HashSet, expand from starts.

Why this. Only start a run if x−1 is not in the set. Each number visited twice → O(n).

Brute. Sort unique, scan. Time O(n log n). Space O(n).

Optimal. HashSet O(n) average. Time O(n). Space O(n).

if (!set.contains(x-1)) { /* expand x, x+1, … */ }

This is values, not indices. Not a sliding window on the array order.

Reorganizing linked lists (1→5→2→4→3) IE-asked

Question they ask. Reorder a list to L0→Ln→L1→Ln−1→… Example they wrote 1→5→2→4→3. Ask if that is fold or odd-even split.

Example. 1→2→3→4→5 → 1→5→2→4→3.

Dry run — walk this before you code.

StepWhat you holdResult / why
midslow/fast; split 1→2→3 and 4→5For odd, mid stays with left.
reverse tail5→4In-place reverse.
weave1→5→2→4→3Array copy is O(n) extra space — they may allow it; optimal is O(1) extra.

Say out loud. Mid + reverse + merge. Ask the exact target order. No invented LC id.

Source. TUF 04 live R3. No URL.

Clue → pattern. Reorder / odd-even / fold the list → slow-fast + reverse second half + merge.

Why this. Classic reorder: find mid, reverse tail, weave. The example 1→5→2→4→3 is fold (L0, Ln, L1, Ln−1, …).

Brute. Copy to array, rewrite. Time O(n). Space O(n).

Optimal. In-place O(n) time O(1) extra. Time O(n). Space O(1).

// mid; reverse(slow.next); weave head and second

Ask the exact target order. Do not invent an LC id.

Reschedule Meetings for Maximum Free Time I IE-asked

Question they ask. Meetings on a timeline; you may reschedule k meetings (classic: move k consecutive) to maximize a free gap. TUF linked the LC title. Meeting Rooms II is the other R2 problem on that IE.

Example. Gaps between meetings [1,2,3,1], k=1 move ⇒ you merge 2 consecutive gaps. Max 2+3=5.

Dry run — walk this before you code.

StepWhat you holdResult / why
gapsstart[i]−end[i−1], plus start-of-day and end-of-day if they countMoving k consecutive meetings merges k+1 gaps.
windowmax sum of k+1 consecutive gapsO(n). Subset of k moves is exponential.
MR IImin rooms is max overlap — different problemSame IE, other title.

Say out loud. Gap array + sliding window. Not Job 10454435.

Source. TUF 06 live R2. Page linked LC title.

Clue → pattern. Gaps between meetings, you may move k meetings → max gap after sliding a window of gaps.

Why this. Moving k consecutive meetings merges k+1 gaps. Sliding window on the gap array.

Brute. Try every subset of k moves. Time exp. Space O(n).

Optimal. Gap array + window of k+1 gaps. Time O(n). Space O(n).

// gaps[i] = start[i]-end[i-1]; max sum of k+1 consecutive gaps

TUF linked a title. Still not Job 10454435. Meeting Rooms II is the other R2 problem on that IE.

Word Ladder II IE-asked

Question they ask. Word Ladder II: all shortest transformation sequences from begin to end.

Example. hit→cog, dict as usual. All shortest paths of length 5, not every path.

Dry run — walk this before you code.

StepWhat you holdResult / why
BFS layersrecord parents only from the previous layerDo not DFS the whole dict first.
found endstop adding deeper layers; still finish the current layerThen DFS from end via parents.
I vs III returns length; CAT→MEN GFG is III can be output-huge — mention it.

Say out loud. BFS parents + DFS collect. Exponential output, polynomial graph.

Source. TUF 06 live R3.

Clue → pattern. All shortest transformation sequences → BFS layers + parent lists, then DFS collect.

Why this. I is shortest length; II is all paths of that length. Do not DFS the whole dict first.

Brute. DFS all sequences, keep min. Time exp. Space O(dict).

Optimal. BFS parents per layer; DFS back. Time O(N L 26 + paths). Space O(N).

// map word -> parents found at dist-1; then dfs from end

Word Ladder I only returns length. CAT→MEN GFG is I.

Most Stones Removed with Same Row or Column (similar) IE-asked

Question they ask. Stones on a 2D grid; remove a stone if it shares a row or column with another. Max removals. Similar-to. Connecting Cities is MST, not this.

Example. Stones (0,0),(0,2),(1,1),(2,0),(2,2). Connected via rows/cols into components. Answer n − components.

Dry run — walk this before you code.

StepWhat you holdResult / why
componentyou can remove all but one stone per componentAnswer = n − #components.
DSUunion stone with row key and col keyOr union stones that share row/col. O(n α(n)) after O(n) or O(n²) pairing.
not MSTTUF 10 Connecting Cities is KruskalSimilar-to this card is DSU, not edge weights.

Say out loud. n − connected components. Directed? No — share row/col is undirected.

Source. TUF 08 live R2.

Clue → pattern. Remove if share row/col → DSU on stones; leftover = components.

Why this. You can remove all but one stone per connected component. Answer = n − components.

Brute. DFS on n² pair graph. Time O(n²). Space O(n).

Optimal. DSU keyed by row and ~col. Time O(n α(n)). Space O(n).

// union(stone, rowKey); union(stone, colKey); comps = unique finds

Similar-to. Connecting Cities (TUF 10) is MST, not this.

Connecting Cities With Minimum Cost IE-asked

Question they ask. n cities, bidirectional connections with cost. Min cost to connect all, or −1. FTE TUF 10, not intern MST.

Example. 3 cities, edges 1-2 cost 5, 1-3 cost 6, 2-3 cost 1. MST cost 6 (2-3 and 1-2).

Dry run — walk this before you code.

StepWhat you holdResult / why
Kruskalsort edges; DSU union if different comps; add costIf final comps > 1, return −1.
PrimPQ from city 1, skip visitedSame answer.
internTUF intern MST is INTERNThis title is FTE TUF 10.

Say out loud. MST. Disconnected → −1. Not stones-on-a-grid.

Source. TUF 10 live R2.

Clue → pattern. Connect all cities min cost → MST Kruskal/Prim.

Why this. If the graph is disconnected, −1. Kruskal: sort edges, DSU. Prim: PQ from 0.

Brute. All spanning trees. Time exp. Space O(n).

Optimal. O(E log E) Kruskal. Time O(E log E). Space O(n).

// sort edges by cost; if union add cost; if comps>1 return -1

Intern MST TUF journey is INTERN. FTE TUF 10 is this title.

First non-repeating character in a stream IE-asked

Question they ask. Stream of characters; after each append, the first character that has appeared exactly once so far (or #).

Example. stream a,a,b,c → after 1: a; after 2: # (a repeated); after 3: b; after 4: b.

Dry run — walk this before you code.

StepWhat you holdResult / why
count[256]increment on each charQueue holds candidates in arrival order.
pop while count[front]>1front is the first uniqueRescan prefix each time is O(n²).
OA unique charstatic string, return index — different slot, still OA-not-a-roundThis card is the stream.

Say out loud. Queue + counts. O(n).

Source. TUF 11 live R3. Page linked a slightly different title.

Clue → pattern. Stream, first unique so far → queue + count[256].

Why this. Count hits; queue holds candidates in order; pop front while count>1.

Brute. Rescan the prefix each append. Time O(n²). Space O(1).

Optimal. O(n) queue + counts. Time O(n). Space O(Σ).

while (!q.isEmpty() && cnt[q.peek()]>1) q.poll();

OA First Unique Character is a static string — different slot, still OA-not-a-round.

Maximum Points on a Line IE-asked

Question they ask. Max number of points that lie on one straight line.

Example. Points (1,1),(2,2),(3,3),(0,1) → 3 on the diagonal.

Dry run — walk this before you code.

StepWhat you holdResult / why
origin imap reduced slope (dy/g, dx/g) → countNormalize sign so −1/2 and 1/−2 match.
verticaldx=0 special keyDuplicates at the same point: add to every line through i.
triples bruteO(n³) collinear testO(n²) from each origin.

Say out loud. Slope map per origin. gcd the fraction. Vertical is a key.

Source. TUF 12 live R2.

Clue → pattern. Largest collinear set → for each origin, map slope → count.

Why this. Slope as reduced fraction (dx/g, dy/g) with sign normalize. Duplicates at the same point handled separately.

Brute. All triples collinear. Time O(n³). Space O(1).

Optimal. O(n²) slopes from each i. Time O(n²). Space O(n).

// key = dy/g + ":" + dx/g; skip i==j; max + duplicates

Vertical line dx=0 is a special key.

Sequentially Ordinal Rank Tracker IE-asked

Question they ask. Add a restaurant (name, rating); query the k-th best so far (higher rating, then name). TUF linked the LC title. Sibling: dynamic k-th LC 7850431.

Example. add (kimchi, 4), (cafe, 5), (sushi, 4). Query 1st → cafe. Query 2nd → kimchi vs sushi by name.

Dry run — walk this before you code.

StepWhat you holdResult / why
comparerating desc, name ascTreeSet of pairs, or two heaps like running k-th.
brutesort all on each queryO(q n log n). log n per add/query with a balanced tree.
not 10454435named on TUFDynamic k-th in §1 is the bible sibling.

Say out loud. Balanced tree or two heaps. Speak the comparator.

Source. TUF 13 live R2. Page linked LC title.

Clue → pattern. Add restaurant, query k-th best so far → two heaps or TreeMap policy.

Why this. Like a dynamic k-th with a compare (rating, name). Balance a “best” side and a “rest” side so peek is the current queried rank.

Brute. Sort the list each query. Time O(q n log n). Space O(n).

Optimal. Two heaps / TreeSet of pairs. Time O(log n). Space O(n).

// TreeSet with (rating desc, name asc); keep iterator / two sets

Named title on TUF. Not a 10454435 lock. Dynamic k-th LC 7850431 is the bible sibling.

Cousins in Binary Tree II IE-asked

Question they ask. Cousins II: replace each node’s value with the sum of its cousins (same depth, different parent). Cousins I is only a boolean — ask which.

Example. Perfect small tree: root 1, left 2 right 3, 2 has 4, 3 has 5. Level-2 sum 9. Node 4’s cousins = 5, so 4 becomes 5 (or levelSum − siblings).

Dry run — walk this before you code.

StepWhat you holdResult / why
level sumBFS sum each depthCousin sum = levelSum − (you + your siblings).
parent groupsneed the sibling clusterTwo BFS or store parent.
I vs III asks if two nodes are cousinsII is the rewrite.

Say out loud. BFS level sums minus sibling group. O(n).

Source. TUF 13 live R2. Linked LC title.

Clue → pattern. Replace each node with cousin-sum (same depth, different parent) → two BFS or one BFS with level sums.

Why this. Level sum minus the two children of your parent is the cousin sum. Need parent grouping.

Brute. For each node scan the level. Time O(n²). Space O(n).

Optimal. BFS store levelSum; second pass set val = levelSum − siblingCluster. Time O(n). Space O(n).

// first BFS depths/sums; second assign

Cousins I is a boolean. II is the value rewrite. Ask which.

Find the Smallest Divisor Given a Threshold IE-asked

Question they ask. Smallest divisor d such that sum of ceil(a[i]/d) ≤ threshold. Not “smallest d that divides every a[i].”

Example. a=[1,2,5,9], threshold=6. d=5 → ceil 1+1+1+2=5 ≤6. d=4 → 1+1+2+3=7>6. Answer 5.

Dry run — walk this before you code.

StepWhat you holdResult / why
monotonelarger d → smaller sumBS d from 1..max(a).
feasible(5)5 ≤ 6Try smaller? 4 fails. Answer 5.
Koko familysame shapeNot gcd of the array.

Say out loud. BS on d + ceil sum. O(n log MAX).

Source. TUF 13 live R3. Linked LC title.

Clue → pattern. Min divisor so sum(ceil(a[i]/d)) ≤ threshold → BS on answer.

Why this. Larger d shrinks the sum — monotone. Same family as Koko.

Brute. Try d=1..max(a). Time O(MAX · n). Space O(1).

Optimal. O(n log MAX). Time O(n log MAX). Space O(1).

feasible(d): sum (a[i]+d-1)/d <= threshold

Not “smallest number that divides all.”

Maximum Level Sum of a Binary Tree IE-asked

Question they ask. 1-based level with maximum node-sum in a binary tree. Tie: smallest level (classic) — confirm.

Example. Root 1, left 7 right 0, 7 has 7 and −8. Level1=1, level2=7, level3=−1. Max is 7 at level 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
BFSint size = q.size(); long s=0Track best.
not widthTUF 11 max width uses indicesThis is sums.
longn * |val| can overflow intSay it.

Say out loud. BFS. O(n). Tie-break: ask.

Source. TUF 13 live R3.

Clue → pattern. BFS level sums, track max and the 1-based level.

Why this. Queue size is the level. long sums.

Brute. DFS with map level→sum. Time O(n). Space O(n).

Optimal. BFS O(n). Time O(n). Space O(w).

for (sz=q.size(); sz>0; sz--) { sum += poll.val; offer kids; }

Max width uses indices, not sums — TUF 11.

LCA of a Binary Tree II (org-chart DS, nodes may be missing) IE-asked

Question they ask. LCA when p or q might not be in the tree (return null if missing). They also wanted an org-chart DS with O(log n) queries. TUF 21 is LCA III (parent pointers) — do not mix.

Example. Tree 3/5,1; p=5 q=4 but 4 not in tree → null. If both exist, normal LCA.

Dry run — walk this before you code.

StepWhat you holdResult / why
found flagsDFS returns whether p and q were seenClassic LCA assumes both exist — that is the trap.
org-chartdepth + binary lifting, or parent chain + HashSetO(log n) after preprocess. Design-a-DS wording is TUF 14.
not IIIIII has parent on the node, no root requiredDifferent card.

Say out loud. Confirm both found. Lifting if they asked log n queries.

Source. TUF 14 live R2. Also bible org-chart DS O(log n) aim.

Clue → pattern. LCA when p or q might not exist → search must confirm both found. Org-chart O(log n) is parent pointers / binary lifting / first+last Euler.

Why this. Classic LCA assumes both exist. II returns null if one is missing — track found flags. Hierarchy DS they wanted O(log n): store depth + jump table or parent chain + HashSet.

Brute. Root-to-node paths lists, last common. Time O(n). Space O(n).

Optimal. One DFS with found flags; or lifting O(log n) after O(n log n) preprocess. Time O(n) or O(log n) query. Space O(n) or O(n log n).

// lca(u) returns node; boolean[] foundP foundQ; if !(foundP&&foundQ) return null

TUF 21 is LCA III (parent pointers on nodes). Do not mix. Design-a-DS wording is TUF 14.

LRU linked, body said LFU IE-asked

Question they ask. The TUF link said LRU; the body said LFU. Say the conflict. Implement whichever they speak. Not Login Tracker.

Example. If they say LRU: cap=2, put 1, put 2, get 1, put 3 → evict 2. If LFU: see the LFU card.

Dry run — walk this before you code.

StepWhat you holdResult / why
say it“The write-up mixed LRU and LFU. Which eviction?”Then code one.
LRUHashMap + DLLO(1).
LFUfreq buckets + minFreqO(1). Do not add freq if they said LRU.

Say out loud. Name the conflict. Login Tracker is unverified and not this.

Source. TUF 15 live R3. URL vs body conflict.

Clue → pattern. Say the conflict. Implement the one they speak. LRU = HashMap+DLL. LFU = freq buckets.

Why this. If the interviewer says LFU, min-freq + LRU inside that freq. If they say LRU, do not add freq.

Brute. Scan keys. Time O(n). Space O(n).

Optimal. O(1) the structure they named. Time O(1). Space O(cap).

// ask: LRU or LFU? write that one

Write the conflict out loud. Not Login Tracker.

Minimum Days to Make M Bouquets IE-asked

Question they ask. bloomDay[i] is the day flower i blooms. You need m bouquets of k adjacent flowers. Min day, or −1.

Example. bloom [1,10,3,10,2], m=3, k=1. After day 3, flowers 0,2,4 are bloomed — three singles. Answer 3.

Dry run — walk this before you code.

StepWhat you holdResult / why
day Dbloomed if a[i]≤D; count adjacent groups of exactly kLarger D helps. BS on D.
m=3 k=2need three pairs of adjacent — may be −1If m*k > n, −1 immediately.
not a heapmonotone day, not “always pick min bloom”Koko family.

Say out loud. BS on day + greedy adjacent count. O(n log MAX).

Source. TUF 16 live R2.

Clue → pattern. Min day so you can pick m adjacent-k groups → BS on day + greedy count.

Why this. After day D, bloomed[i]=true if a[i]≤D. Count adjacent groups of k. Larger D helps.

Brute. Try every day. Time O(MAX · n). Space O(1).

Optimal. O(n log MAX). Time O(n log MAX). Space O(1).

// feasible(D): adjacent bloom count / k >= m

Same monotone family as Koko. Not a heap of flowers.

Distinct Subsequences IE-asked

Question they ask. Number of times t appears as a subsequence of s (not substring).

Example. s=rabbbit, t=rabbit → 3 ways (the three b’s choose two).

Dry run — walk this before you code.

StepWhat you holdResult / why
dp[j]ways to form t[:j]If s[i]==t[j], dp[j] += dp[j-1] walking j backward so you do not reuse.
not LISthis is counts, not longest increasingO(n m).
modask 10^9+7If they want it.

Say out loud. DP subsequence counts. Not distinct elements of the array.

Source. TUF 16 live R2.

Clue → pattern. Ways t occurs as subsequence of s → DP.

Why this. dp[i][j] = ways to form t[:j] from s[:i]. If s[i-1]==t[j-1] add dp[i-1][j-1].

Brute. Recurse all subsequences. Time O(2^n). Space O(n).

Optimal. O(n m) DP, rolling 1D backward. Time O(n m). Space O(m).

if (s[i]==t[j]) dp[j] += dp[j-1]; iterate j from m..1

Not LIS. Not “distinct count of the array.”

Evaluate Reverse Polish Notation IE-asked

Question they ask. Evaluate Reverse Polish Notation. Tokens are numbers or + − * /.

Example. [2, 1, +, 3, *] → (2+1)*3 = 9.

Dry run — walk this before you code.

StepWhat you holdResult / why
push 2,1see + : pop 1, pop 2, push 3Order: a op b with b popped first.
push 3, see *pop 3, pop 3, push 9Use long. Integer division toward zero — ask.
infixbasic-calc card is signs and parensThis is postfix.

Say out loud. Stack of longs. O(n). The stack is the algorithm, not a ‘brute vs opt’ story.

Source. TUF 17 live R2.

Clue → pattern. Postfix tokens → stack of longs.

Why this. Number push; operator pop two (watch order: a op b with b popped first).

Brute. Not really — the stack is the definition. Time O(n). Space O(n).

Optimal. ArrayDeque. Time O(n). Space O(n).

if (op) { int b=st.pop(), a=st.pop(); st.push(a?b); } else st.push(parse)

Infix calculator is a different stack (signs/parens).

Strong Password Checker IE-asked

Question they ask. Min changes so the password is strong: length in [6,20], has lower/upper/digit, no three identical in a row. Hard casework. Not a random edit-distance DP.

Example. aaa → need length and types and break the run. Speak cases: len<6, len in 6..20, len>20.

Dry run — walk this before you code.

StepWhat you holdResult / why
missing types0–3 inserts/replacesRuns of 3: replace the 3rd char of each aaa.
too longdeletes that also break runs are worth moreThis is the painful case. O(n) count + casework.
BFS on stringsimpossible at interview nSay you will not BFS the string space.

Say out loud. Case analysis, not generic DP. TUF named it — still not 10454435.

Source. TUF 17 live R2. Linked LC title.

Clue → pattern. Min changes to satisfy length / classes / 3-run → greedy counts, not a generic DP.

Why this. This problem is a special case analysis (missing types, aaa runs, length <6 / >20). Speak the cases; do not invent a random edit-distance.

Brute. BFS on strings. Time huge. Space huge.

Optimal. O(n) count + casework. Time O(n). Space O(1).

// count missing lower/upper/digit; count run lengths %3

Hard. Say the cases out loud. Not Job 10454435 just because TUF named it.

Closest Divisors (kind of like) IE-asked

Question they ask. Kind-of-like closest divisors: pair of factors of n or n+1 with smallest |a−b|. Same R3 had unnamed topo — do not stamp extra ids.

Example. n=8. Factors of 8: (1,8),(2,4). Factors of 9: (1,9),(3,3). Closest is (3,3).

Dry run — walk this before you code.

StepWhat you holdResult / why
sqrt walki from (int)sqrt(x) down, if x%i==0 return (i, x/i)Do for x=n and x=n+1, pick closer pair.
O(√n)not 1..nKind-of-like.
topo leftoverunnamedDo not invent it.

Say out loud. Walk from sqrt. Use long if n is big.

Source. TUF 17 live R3. Similar-to.

Clue → pattern. Pair of factors of n or n+1 closest → walk i from sqrt down.

Why this. For x in {n, n+1} find i|x minimizing |x/i − i|. Start i=sqrt(x).

Brute. All i=1..x. Time O(n). Space O(1).

Optimal. O(sqrt n). Time O(√n). Space O(1).

for (int i=(int)Math.sqrt(x); i>=1; i--) if (x%i==0) return {i,x/i};

Kind-of-like. Same R3 also had unnamed topo. Do not stamp an extra LC id.

Assign Cookies IE-asked

Question they ask. Assign cookies: g[i] greed, s[j] size, one cookie per child if s[j]≥g[i]. Maximize content children. Follow-up may allow stacking cookies — that is a new problem.

Example. g=[1,2,3] s=[1,1] → 1 child.

Dry run — walk this before you code.

StepWhat you holdResult / why
sort bothg 1,2,3 s 1,1Smallest remaining greed: 1 gets a 1. Next 2 cannot.
two pointerO(n log n)Assignments brute is exponential.
follow-up stackcan multiple cookies fill g[i]?Knapsack/greedy remaining — ask. Do not silently keep one-cookie.

Say out loud. Sort + greedy. Speak the follow-up as a new model.

Source. TUF 18 live R2. Follow-up: one child can take multiple cookies.

Clue → pattern. Greedy: sort both, smallest-greed child first. Follow-up changes the model — ask if cookies stack.

Why this. Classic: one cookie per child, g[i]≤s[j]. Follow-up “multiple cookies” is a different packing (can you sum cookies to meet g[i]) — knapsack-ish or greedy remaining.

Brute. Try assignments. Time exp. Space O(n).

Optimal. Sort + two pointer O(n log n). Time O(n log n). Space O(1).

Arrays.sort(g); Arrays.sort(s); while i=g[i]) i++; j++;

Speak the follow-up as a new problem. Do not silently keep one-cookie.

Daily Temperatures IE-asked

Question they ask. Daily Temperatures: for each day, days until a warmer temp (0 if none). Same stack as NGE / Naina similar-to.

Example. [73,74,75,71,69,72,76,73] → [1,1,4,2,1,1,0,0].

Dry run — walk this before you code.

StepWhat you holdResult / why
73next 74 in 1 dayans=1.
7576 is 4 laterDecreasing stack of indices. Distance = j−i.
templateone stack with NGE in §1Named on TUF 18 too.

Say out loud. Monotonic stack O(n). Nested scan is O(n²).

Source. TUF 18 live R2. Named title. Bible Naina was similar-to.

Clue → pattern. NGE distances — section A stack.

Why this. Same monotonic stack as NGE.

Brute. O(n²). Time O(n²). Space O(1).

Optimal. O(n). Time O(n). Space O(n).

ans[i] = j - i;

Named on TUF 18; similar on Naina. One template.

Bottom View of Binary Tree IE-asked

Question they ask. Bottom view of a binary tree: leftmost to rightmost horizontal column, the lowest node in that column.

Example. Root 20, left 8 right 22, 8 has 5 and 3, 3 has 10, 22 has 25. Bottom view 5,10,3,22,25 (classic GFG drawing — use theirs).

Dry run — walk this before you code.

StepWhat you holdResult / why
BFS(node, col). later node at same col overwritesBFS guarantees lower (deeper) wins. DFS must compare depth.
TreeMap col→valor HashMap + min/max colTop view keeps the first, not the last.
vertical orderkeeps the list, not one nodeDifferent problem.

Say out loud. BFS + column map. Last write wins.

Source. TUF 18 live R3.

Clue → pattern. Horizontal column, last node in vertical BFS → TreeMap col→val.

Why this. BFS so a lower node overwrites the same column. DFS must compare depth.

Brute. All nodes, keep max depth per col. Time O(n log n) if tree map. Space O(n).

Optimal. BFS + TreeMap or HashMap+min/max col. Time O(n log W). Space O(n).

q.offer({node,0}); map.put(col, node.val); // BFS overwrites

Top view keeps the first, not the last. Vertical order keeps the list.

Apply Operations to an Array IE-asked

Question they ask. If a[i]==a[i+1] and nonzero, a[i]*=2, a[i+1]=0; then shift zeros to the end.

Example. [1,2,2,1,1,0] → after ops [1,4,0,2,0,0] then compact [1,4,2,0,0,0].

Dry run — walk this before you code.

StepWhat you holdResult / why
pass 1i from 0 to n-2: equal pair → double and zero nextSimulation is the problem.
pass 2write pointer for non-zerosArrayList rebuild is extra space.
not a heapO(n)Easy-medium. Still say TC.

Say out loud. Two passes in place. Do not invent a fancy DS.

Source. TUF 18 live R3. Linked LC title.

Clue → pattern. If a[i]==a[i+1] double and zero the next; then compact zeros — one/two passes.

Why this. Simulation is the problem. Second pass move non-zeros forward.

Brute. ArrayList rebuild. Time O(n). Space O(n).

Optimal. In-place O(n). Time O(n). Space O(1).

if (a[i]==a[i+1] && a[i]!=0) { a[i]*=2; a[i+1]=0; } then partition zeros

Easy-medium. Still say TC. Do not invent a heap.

Largest Submatrix With Rearrangements IE-asked

Question they ask. You may rearrange columns. Largest area submatrix of all 1s. Not Maximal Rectangle (that forbids reorder).

Example. After sorting heights in a row, height 3,2,1 → areas 3*1, 2*2, 1*3 → best 4.

Dry run — walk this before you code.

StepWhat you holdResult / why
heightsconsecutive 1s ending at this row, per columnSame histogram heights as Maximal Rectangle.
sort descendingarea = height[j] * (j+1) after sortBecause you may permute columns.
no reorderthat is Maximal Rectangle + stackDifferent card in §1.

Say out loud. Heights + sort per row. O(m n log n). Not the stack histogram without permutation.

Source. TUF 18 live R4 HM. Linked LC title.

Clue → pattern. You may reorder columns; largest 1s-area → height histogram per row, sort heights, greedy width.

Why this. Unlike Maximal Rectangle, columns can be permuted. For each row, treat heights, sort descending, area = height[j]*(j+1).

Brute. All permutations of columns. Time O(n! · mn). Space O(mn).

Optimal. O(m n log n) sort per row. Time O(m n log n). Space O(n).

// update height; copy sort desc; ans=max(h[j]*(j+1))

Not the same as Maximal Rectangle (no reorder).

Digit Count in Range IE-asked

Question they ask. Count how many times digit d appears in all numbers in [a,b].

Example. d=1, [1,13]: 1,10,11,12,13 → 1 six times (11 counts twice). If b is 1e12, brute dies.

Dry run — walk this before you code.

StepWhat you holdResult / why
tiny bloop x=a..b, count digitsHonest if they gave b≤1e6.
large bcount(0..b) − count(0..a−1) digit DPPosition, tight, leading-zero flags.
do not flexif n is small, brute is the interviewAsk bounds first.

Say out loud. Bounds decide brute vs digit DP. Do not start DP on 1e5.

Source. TUF 19 live R3.

Clue → pattern. Count digit d in [a,b] → digit DP or count(0..b)−count(0..a−1).

Why this. Digit DP on positions, tight flag, leading zeros. Brute loop is fine if b is small — ask the bounds.

Brute. For each x in [a,b] count digits. Time O((b−a) · D). Space O(1).

Optimal. Digit DP O(D · 2 · 2 · 10). Time O(D). Space O(D).

// count(n,d) digit-DP; return count(b)-count(a-1)

If they gave tiny b, brute is honest. Do not flex digit-DP if n≤1e6 and they want simple.

Majority Element I IE-asked

Question they ask. Element that appears more than n/2 times. Guaranteed to exist on I.

Example. [2,2,1,1,1,2,2] → 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
Boyer-Moorecandidate 2, count up/downVerify with a second pass if not guaranteed.
HashMapO(n) time O(n) space — brute-ishSort n log n also works.
IIn/3 needs two candidatesDo not mix.

Say out loud. Moore O(1) space. Majority II is different.

Source. TUF 20 live R1 (this IE’s R1 was live DSA, not OA).

Clue → pattern. Element with count > n/2 → Boyer-Moore or HashMap.

Why this. Moore: candidate + count; verify. Sorting also works n log n.

Brute. HashMap all counts. Time O(n). Space O(n).

Optimal. Boyer-Moore O(n) O(1). Time O(n). Space O(1).

if (x==cand) c++; else if (--c==0) cand=x;

Majority II is n/3 — different.

Frog Jump IE-asked

Question they ask. Frog on stones at positions. First jump is 1. From a jump of k, next is k−1, k, or k+1. Can it reach the last stone?

Example. stones [0,1,3,5,6,8,12,17] → true (classic). [0,1,2,3,4,8,9,11] → false.

Dry run — walk this before you code.

StepWhat you holdResult / why
state(index or position, lastJump k)Set of stone positions for O(1) “is there a stone at pos+k”.
DPpossible k’s at each stoneO(n²). Recurse without memo is exponential.
year-out GFGsame patternNot a sliding window.

Say out loud. DP/BFS on (stone, k). Need a position set.

Source. TUF 20 live R1. Also pre-2024 dump title.

Clue → pattern. Can the frog reach last stone with jump k−1,k,k+1 → DP/BFS on (index,k).

Why this. State is (stone, lastJump). Set of stone positions for O(1) hit.

Brute. Recurse jumps. Time exp. Space O(n²).

Optimal. DP set of possible k per stone O(n²). Time O(n²). Space O(n²).

if (stones.contains(pos+step)) dfs(pos+step, step)

GFG dump Frog Jump is year-out too. Same pattern.

Maximum Consecutive Good Numbers IE-asked

Question they ask. Maximum consecutive good numbers. TUF linked a title; body may be thin. Ask what “good” means before you code.

Example. If good is a[i] % 2 == 0: [1,2,4,3,6,8,5] longest even run is 2,4 length 2 or 6,8 length 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
predicate on one elementscan, reset on badO(n). All L,R is O(n²) theatre.
predicate on a windowthen it is a sliding window — they must define itDo not invent.
no extra LC idaskTitle named, mechanism maybe not.

Say out loud. Lock “good.” Then linear scan or window. No guessed id.

Source. TUF 20 live R2.

Clue → pattern. Ask their definition of good; then longest run — window or simple scan.

Why this. If good is a predicate on a[i], longest consecutive trues is a linear scan. If good depends on a window, it is a sliding window.

Brute. All L,R test. Time O(n²). Space O(1).

Optimal. O(n) once the predicate is monotone or per-element. Time O(n). Space O(1).

// ask: is good(a[i]) independent? then scan runs

TUF linked a title; body may still be thin. Ask. No extra LC id.

Find Peak Element IE-asked

Question they ask. A peak is a[i] > neighbors (ends: one neighbor). Array is unsorted. O(log n) expected.

Example. [1,2,3,1] peak index 2 (value 3). [1,2,1,3,5,6,4] 1 or 5 both peaks — any peak.

Dry run — walk this before you code.

StepWhat you holdResult / why
mid vs mid+1if a[mid] < a[mid+1], a peak exists on the rightThe array must have a peak; slope argument.
elsesearch left including midO(log n). Linear scan is the brute.
not 2D peaknot rotated minimumDifferent BS cards.

Say out loud. Binary search the slope. Return any peak.

Source. TUF 20 live R2.

Clue → pattern. a[i]>neighbors, unsorted, O(log n) → BS the slope.

Why this. If mid < mid+1 there is a peak on the right. Unimodal argument on the array they guaranteed.

Brute. Linear scan. Time O(n). Space O(1).

Optimal. O(log n) BS. Time O(log n). Space O(1).

if (a[mid] < a[mid+1]) lo=mid+1; else hi=mid;

2D peak is a different BS. Rotated min is a different BS.

Count the Number of K-Big Indices IE-asked

Question they ask. Index i is k-big if ≥ k elements to the left are < a[i] and ≥ k to the right are < a[i]. Count them. Intern OA TUF Q47 is INTERN; FTE TUF 21 is live R2.

Example. a=[2,3,6,5,2,3], k=2? Walk i=2 (6): left 2,3 both <6 (2 elements); right 5,2,3 → two <6. If k=2, i=2 counts. Confirm on their array.

Dry run — walk this before you code.

StepWhat you holdResult / why
brutefor each i scan left and rightO(n²). Fine to name.
Fenwickcompress values; left-to-right add, query smaller count; then right-to-leftO(n log n).
interndo not treat intern OA as your R3FTE TUF 21 is this live title.

Say out loud. Count left-smaller and right-smaller. BIT after you name the brute.

Source. TUF 21 live R2. Intern OA also named this family.

Clue → pattern. Index i is k-big if k elements to the left and to the right are < a[i] — Fenwick/merge or sorted structures.

Why this. Need left-smaller count and right-smaller count both ≥ k. Fenwick on compressed values, left-to-right then right-to-left.

Brute. For each i scan left and right. Time O(n²). Space O(1).

Optimal. O(n log n) BIT. Time O(n log n). Space O(n).

// fenwick add ranks; left[i]=query(rank[i]-1)

Intern OA TUF Q47 is INTERN. FTE TUF 21 is live R2.

Search in 2D Matrix II IE-asked

Question they ask. Matrix with each row and each column sorted. Search a target. Not 2D Matrix I (flatten + one BS).

Example. [[1,4,7],[2,5,8],[3,6,9]], target 8. Start at 7 (top-right): 8>7 go down to 8. Found.

Dry run — walk this before you code.

StepWhat you holdResult / why
top-rightif cur > target go left; if cur < target go downO(m+n). Never up/right.
Matrix Ifirst of row i > last of row i−1 — one BS on n*mWrong here: 4 is above 2.
max 1ssame walk on a 0/1 row-sorted matrixSister card.

Say out loud. Staircase O(m+n). Do not flatten.

Source. TUF 21 live R2.

Clue → pattern. Rows and columns sorted → staircase from top-right O(m+n).

Why this. If cur > target, go left; if cur < target, go down. Not a single BS on a flattened array (that is Matrix I).

Brute. Scan all / BS each row. Time O(mn) / O(m log n). Space O(1).

Optimal. O(m+n). Time O(m+n). Space O(1).

int r=0,c=n-1; while (r=0) { if (a[r][c]==t) return; if (a[r][c]>t) c--; else r++; }

Max-1s row uses the same walk on a 0/1 matrix.

Maximum Alternating Subarray Sum (variation) IE-asked

Question they ask. Maximum alternating subarray sum (variation). Ask if contiguous (subarray) vs subsequence. Sign pattern + − + or they define it.

Example. If subarray +−+: [3, −1, 4] may be 3−(−1)+4 if they flip actual signs, or 3 + (−(−1)) + 4 — lock the formula. Simpler: [1,2,3] alt 1−2+3=2 vs 2−3=−1 vs 3; DP two states.

Dry run — walk this before you code.

StepWhat you holdResult / why
statesbest ending with + contribution, best ending with −Kadane-like, O(n).
contiguous?subarray vs subsequence is a different LC familyAsk. Variation.
all L,RO(n²) bruteThen upgrade.

Say out loud. Two-state DP after they define the signs. Ask contiguous.

Source. TUF 21 live R3. Variation.

Clue → pattern. Alternating + − + pattern → DP two states (end-plus, end-minus).

Why this. Kadane-like but the sign flips. Variation: ask if subarray must be contiguous (yes if they said subarray).

Brute. All L,R compute alt. Time O(n²). Space O(1).

Optimal. O(n) two states. Time O(n). Space O(1).

plus = a[i]; minus = plus - /*prev*/; track max

Variation. Subsequence alternating is a different LC family — ask contiguous.

Walls and Gates (variation) IE-asked

Question they ask. Walls and Gates variation: 0 = gate, INF = empty room, −1 = wall. Fill each room with dist to nearest gate. 4-dir — ask.

Example. One gate at (0,0), empty at (0,1) and (1,0). Those become 1. Multi-source like rotten oranges.

Dry run — walk this before you code.

StepWhat you holdResult / why
queue all 0sminute/dist 0Do not BFS from every INF cell (that is (mn)²).
spreadINF neighbor ← dist+1Walls block.
variationask the INF sentinelSame shape as rotten.

Say out loud. Multi-source BFS. O(mn).

Source. TUF 21 live R3. Variation.

Clue → pattern. Multi-source BFS from all gates (0s) into empty rooms.

Why this. Same shape as rotten oranges. Do not DFS from each room (that is n times BFS).

Brute. BFS from every INF cell. Time O((mn)²). Space O(mn).

Optimal. Queue all 0s first. Time O(mn). Space O(mn).

// offer all gates; dist++; skip walls -1

Variation — ask INF sentinel and 4-dir.

LCA of a Binary Tree III IE-asked

Question they ask. LCA III: TreeNode has a parent pointer. No root given. Not II (missing nodes). Not org-chart lifting unless they asked preprocess.

Example. p and q in a tree, climb. Like intersecting linked lists.

Dry run — walk this before you code.

StepWhat you holdResult / why
set of p’s parentswalk p to null, then walk q until hitO(h) space.
two pointersequalize depth or cycle like list intersectionO(1) extra if you walk both to root then the difference.
not IIII may return null if a node is missing, and usually no parent fieldDifferent card.

Say out loud. Parent pointers → list-intersection. O(h).

Source. TUF 21 live R4.

Clue → pattern. Nodes have parent pointers → two pointers like intersecting lists, or HashSet of parents.

Why this. Walk p to root storing set; walk q until hit. Or equalize depths then climb together. No tree root required.

Brute. All ancestors of p, scan q. Time O(h). Space O(h).

Optimal. O(h) two pointers. Time O(h). Space O(1) if you cycle like list intersection.

// like intersection of two linked lists via parent

Not II (maybe missing nodes, no parent field). Not org-chart O(log n) DS unless they asked preprocess.

Print all nodes at distance K in BT IE-asked

Question they ask. Print all nodes at distance K from a target in a binary tree. Same family as §1 Distance K / LC 7406809. If they ban a parent map, parent is a DFS argument.

Example. Use the §1 drawing: target 5, k=2 → [1,4].

Dry run — walk this before you code.

StepWhat you holdResult / why
setupundirected edges via parent argThen BFS k layers.
allow map?if yes, Map is fine; if no, do not write Map<TreeNode,TreeNode>They may forbid it.
§1full Java in chapter 05One rehearsal, not two codes.

Say out loud. BFS from target after you can walk up. See Distance K.

Source. TUF 21 live R4. Same family as Distance K.

Clue → pattern. Use the no-parent-map card in section A / ch.05.

Why this. Same problem family as LC 7406809 / 7623949.

Brute. Parent map + BFS (works if they allow the map). Time O(n). Space O(n).

Optimal. Parent as DFS arg + BFS. Time O(n). Space O(n).

// see 05-dsa.html#distance-k-no-parent-map

If they ban the map, do not write Map<TreeNode,TreeNode>.

Maximum Number of Weeks for Which You Can Work (variation) IE-asked

Question they ask. milestones[i] weeks left on project i; cannot work the same project two weeks in a row. Max weeks you can work. Variation. SDE-unspecified file 201 — not a clean UTA loop, not 10454435.

Example. Classic: [1,2,3] → if max ≤ rest+1 you finish all 6; else 2*rest+1. Confirm their rule.

Dry run — walk this before you code.

StepWhat you holdResult / why
max vs restrest = total − maxIf max > rest+1 you get stuck: 2*rest+1.
heap simulatealways pick the current largest remaining that is not lastO(W log n) brute-ish. Closed form O(n) on the classic statement.
variationask the exact constraintUnspecified-SDE file.

Say out loud. Greedy on the max project. Lock the rule. Not 10454435.

Source. TUF 201 unspecified-SDE live R2. Variation.

Clue → pattern. Cannot work the same project two weeks in a row; milestones[] → greedy on max.

Why this. If max ≤ 1+rest you can finish all; else you are stuck after 2*rest+1. Variation: ask their exact rule.

Brute. Simulate a max-heap week by week. Time O(W log n). Space O(n).

Optimal. O(n) closed form on the classic statement. Time O(n). Space O(1).

long rest=sum-max; return max<=rest+1 ? sum : 2*rest+1;

SDE unspecified file 201, not a clean SDE I UTA loop. Variation. Not 10454435.

Replace Non-Coprime Numbers in Array (variation) IE-asked

Question they ask. While two adjacent numbers have gcd > 1, replace them with their LCM. Variation. Use long. Unspecified-SDE file.

Example. [6, 4, 3, 2, 7, 6, 2] classic: 6,4 → lcm 12, then 12,3 → 12, etc. Walk a stack.

Dry run — walk this before you code.

StepWhat you holdResult / why
stackwhile gcd(top, x)>1, pop and x = lcm(top,x)New x may still collide with the new top — loop, not one if.
lcma / gcd * b with longRescan the array after each replace is n².
variationunspecified SDENot UTA-default.

Say out loud. Stack + gcd/lcm while. Long for lcm.

Source. TUF 201 live R2. Variation.

Clue → pattern. While adjacent gcd>1 replace with lcm → stack, gcd/lcm.

Why this. New value may still collide with the new top — while-loop on the stack, not one pass without a stack.

Brute. Rescan the array after each replace. Time O(n² log A). Space O(n).

Optimal. Stack O(n log A). Time O(n log A). Space O(n).

while (!st.isEmpty() && gcd(st.peek(),x)>1) x=lcm(st.pop(),x); st.push(x);

Variation. Use long for lcm. Unspecified-SDE file.

Insertion Sort List (variation + follow-ups) IE-asked

Question they ask. Insertion-sort a linked list. Follow-up: they want faster → merge-sort the list O(n log n), O(1) extra if careful.

Example. 4→2→1→3 → 1→2→3→4.

Dry run — walk this before you code.

StepWhat you holdResult / why
dummyfor each curr, find insert point from dummyO(n²) pointer walks. That is insertion sort.
array sortO(n log n) extra space — mention as not in-placeThey may accept it then ask pointers.
follow-upmerge sort list: split mid, recurse, mergeBe ready. Follow-ups were written.

Say out loud. Insertion is O(n²). Upgrade to merge sort if they ask.

Source. TUF 201 live R3.

Clue → pattern. Sort a linked list by insertion → dummy + walk prev.

Why this. O(n²) is the algorithm’s cost. Follow-ups: merge sort list O(n log n).

Brute. Array sort + rebuild. Time O(n log n). Space O(n).

Optimal. True insertion O(n²) pointers; mention merge sort if they want faster. Time O(n²) or O(n log n). Space O(1).

// dummy; for each cur find insert point in the sorted prefix

Follow-ups were written — be ready to upgrade to merge sort list.

Factor Combinations (variation) IE-asked

Question they ask. All factor combinations of n (usually excluding n itself as a single factor). Backtracking. BR on unspecified-SDE — not UTA-default. Variation.

Example. n=8 → [2,2,2], [2,4], [4,2] if order matters — usually keep non-decreasing: [2,2,2],[2,4].

Dry run — walk this before you code.

StepWhat you holdResult / why
start ifrom last factor (or 2) to sqrt, recurse n/iNon-decreasing kills permutations.
baseif remaining n≥start, append n as last factorExcept the trivial [n] if they exclude it.
not UTA-defaultvariation BROutput-sensitive time.

Say out loud. Backtrack with a start index. Ask whether [n] is allowed.

Source. TUF 201 live R4 BR. Variation.

Clue → pattern. All ways to factor n (excluding n itself usually) → backtracking from last factor.

Why this. Start i from 2 or from last to keep non-decreasing. n≤ a typical backtrack bound.

Brute. Same tree, sloppier duplicates. Time depends on n. Space O(log n).

Optimal. Backtrack i=start..sqrt, recurse n/i. Time output-sensitive. Space O(log n).

for (int i=start; i*i<=n; i++) if (n%i==0) { path.add(i); dfs(n/i,i); path.remove }

BR on an unspecified-SDE write-up. Not UTA-default. Variation.

Basic tree operations / balanced trees (RB, AVL) Standard CS

Question they ask. Conceptual: BST operations, AVL vs Red-Black. Not a LeetCode. Do not claim you implemented RB at Ylogx. Java TreeMap is RB.

Example. Insert 1,2,3 into a BST without rotate → a stick, O(n) search. AVL rotates to a balanced 2-root.

Dry run — walk this before you code.

StepWhat you holdResult / why
AVL|bf|≤1; LL/LR/RR/RL rotatesGuaranteed log n.
RB5 properties; recolor or rotateTreeMap/TreeSet. ceiling/floor O(log n).
why they askwhy HashMap is not sorted; why TreeMap vs heapConceptual. No fake coding prompt.

Say out loud. Speak rotations and invariants. Unbalanced BST is the O(n) warning.

Source. TUF 04 live R2. Conceptual.

Clue → pattern. They asked operations / RB / AVL — speak rotations and invariants, not a fake coding prompt.

Why this. AVL: |bf|≤1, rotate LL/LR/RR/RL. RB: 5 properties, recolor/rotate. Java TreeMap is a RB tree — O(log n) ceiling/floor.

Brute. Unbalanced BST worst O(n). Time O(n). Space O(n).

Optimal. AVL/RB O(log n) guaranteed. Time O(log n). Space O(n).

// TreeMap if they want a balanced BST without writing rotations

Conceptual. Do not invent a LeetCode. Do not claim you implemented RB at Ylogx.

Merge two already-sorted integer streams IE-asked

Question they ask. Merge two already-sorted integer streams (possibly unbounded). Same idea as merge two sorted lists. Not merge k.

Example. A: 1,3,5… B: 2,4. Output 1,2,3,4,5…

Dry run — walk this before you code.

StepWhat you holdResult / why
headsalways emit the smaller currentCannot load both streams fully if unbounded.
concat+sortO(n log n) extra — brute if they are finiteTwo pointer O(n+m).
k streamsthat is merge k + heapDifferent card.

Say out loud. Two pointers / two heads. O(n+m). Do not sort.

Source. TUF 14 described live R3.

Clue → pattern. Two sorted streams → two pointers / heap of 2 heads. Same as merge two sorted lists.

Why this. Always take the smaller current head. If they are true streams (unbounded), you cannot load all.

Brute. Buffer both, concat sort. Time O(n log n). Space O(n).

Optimal. O(n+m) two pointer. Time O(n+m). Space O(1) extra.

// while both: emit min(a,b) advance that iterator

Described, no title. Not merge k (heap of k).

All pairs with given sum IE-asked

Question they ask. All pairs that sum to a target. Sorted → two pointer (skip duplicates). Unsorted → HashMap. Described, no LC id.

Example. [2,7,11,15], target 9 → (2,7). If duplicates [1,1,1,2] target 3, ask unique pairs vs all index pairs.

Dry run — walk this before you code.

StepWhat you holdResult / why
sorted l,r2+15 too big, 2+11 too big, 2+7 hit; move both and skip equalsO(n) after sort.
HashMapneed = t−x; if seen, pairFor all pairs, counts of need.
no LC iddescribedChapter 25 pair-sum.

Say out loud. Lock unique vs all. Then map or two pointer.

Source. TUF 15 described live R2.

Clue → pattern. Pair sum — HashMap or two-pointer if sorted. They want all pairs: skip duplicates.

Why this. See chapter 25 pair-sum. For all pairs, after a hit move both pointers / walk equal-run counts.

Brute. O(n²). Time O(n²). Space O(1).

Optimal. O(n) or O(n log n). Time O(n). Space O(n).

// map value→indices; watch i!=j and unique pairs

Described. No LC id.

BST + float target: k closest values IE-asked

Question they ask. BST (or sorted inorder) and a float target; return k closest values. Not Top K frequent.

Example. BST inorder 1,2,3,4,5, target 3.2, k=2 → 3 and 4 (or 3 and 2 — |3.2−2|=1.2 > |3.2−4|=0.8 so 3,4).

Dry run — walk this before you code.

StepWhat you holdResult / why
inorder arraysorted line; find insert point; expand two pointers to kO(n).
heap size kO(n log k) if you do not use BST structureFine to say.
pred/succ stacksO(k + log n) if they want logDescribed. Not top-k frequency.

Say out loud. Closest on a sorted line. Inorder then two pointers is the clear story.

Source. TUF 15 described live R2.

Clue → pattern. Inorder is sorted; two pointers on the inorder array, or two stacks (pred/succ).

Why this. k closest on a sorted line: expand from the insertion point. Heap of size k also works O(n log k).

Brute. All values, sort by |x−t|. Time O(n log n). Space O(n).

Optimal. Inorder + two pointer O(n), or O(k + log n) pred/succ. Time O(n). Space O(n).

// inorder list; l,r around target; pick closer k times

Described. Not Top K frequent.

Maze: shortest path collect all keys IE-asked

Question they ask. Grid maze: walls, doors A–F, keys a–f. Shortest path to collect all keys. Not Walls and Gates.

Example. Start @, one key a, door A, end when mask has all keys. K ≤ 10 typically.

Dry run — walk this before you code.

StepWhat you holdResult / why
state(r, c, keymask)Plain (r,c) BFS is wrong — you may need to revisit a cell with more keys.
doorenter A only if bit a is setBFS on that state is shortest.
K keys2^K · mnIf K is 15, say it explodes. Not Walls and Gates.

Say out loud. BFS (r,c,mask). O(mn 2^K). Keys must be few.

Source. TUF 15 described live R3.

Clue → pattern. Walls, doors, keys → BFS state (r,c,keymask).

Why this. Keys are bits. Door ‘A’ opens if bit ‘a’ is set. Shortest is BFS on that state, not plain (r,c).

Brute. DFS all key orders. Time exp. Space O(mn · 2^K).

Optimal. BFS O(mn · 2^K). Time O(mn 2^K). Space O(mn 2^K).

q.offer({r,c,mask}); vis[r][c][mask]

Described. K keys must be small (≤10). Not Walls and Gates.

k-th largest from each suffix starting at index k IE-asked

Question they ask. They said k-th largest from each suffix starting at index k, but the example [2,2,3] matched k-th of growing prefixes. Lock the range on their example. Do not stamp a LeetCode.

Example. Array [4,2,1,3], k=2. If prefixes of length ≥2: kth of [4,2]=2, [4,2,1]=2, [4,2,1,3]=3 → [2,2,3]. If they truly mean suffixes, walk from the right instead.

Dry run — walk this before you code.

StepWhat you holdResult / why
say the examplewrite both interpretations, pick theirsExample wins over the word suffix.
growing prefixsize-k min-heap; peek is kth as the prefix growsO(n log k). Copy-sort each range is n² log n.
suffixessame heap from the rightDo not stamp an id.

Say out loud. Lock prefix vs suffix on the example. Then size-k heap.

Source. TUF 05 described. Example [4,2,1,3], k=2 → [2,2,3].

Clue → pattern. For each i≥k−1, k-th of a[i−k+1? wait] — they said suffixes starting at k. Use the example.

Why this. Example: suffixes [4,2,1,3], [2,1,3], [1,3], [3] but they started at index k — walk i from k−1..n−1, structure on a[k−1..i] or on a[i..n−1]. The example [2,2,3] matches k-th largest of prefixes ending at i for i=1..n−1 starting when length≥k: of [4,2]=2, [4,2,1]=2, [4,2,1,3]=3. So it is prefixes from 0, not suffixes. Say the example out loud and lock the range.

Brute. Copy and sort each range. Time O(n² log n). Space O(n).

Optimal. Size-k min-heap sliding on the locked range, or Fenwick if they want each k-th of growing prefix. Time O(n log k). Space O(k).

// lock the range from the example before coding

Described. Do not stamp a LeetCode. Example wins over the word “suffix.”

Line sweep (unnamed) IE-asked

Question they ask. They said line sweep; the exact geometry is unnamed. Sort events on x, scan with a counter or TreeMap of actives. Do not invent skyline as what they asked.

Example. Meetings [1,3],[2,4]: events (1,+1),(3,−1),(2,+1),(4,−1). Sort, scan; max overlap 2.

Dry run — walk this before you code.

StepWhat you holdResult / why
events(x, type). sort x, ends before starts if they do not want touching to countAsk closed vs open.
scancounter += type; track max or union lengthAll-pairs overlap is O(n²).
unnameddo not claim they asked The Skyline ProblemPattern only. Chapter 25.

Say out loud. Sort events, scan. Stay unnamed on the exact prompt.

Source. TUF 03 live R2. Title not given.

Clue → pattern. Line sweep → sort events, scan with a counter or TreeMap of actives.

Why this. Meetings, skyline, overlapping: events (x, +1/−1), sort, scan. Stay unnamed on the exact geometry.

Brute. All pairs overlap. Time O(n²). Space O(1).

Optimal. O(n log n) events. Time O(n log n). Space O(n).

// events.sort; cur+=delta; ans=max(ans,cur)

UNNAMED exact prompt. Do not invent skyline as what they asked.

4. Unnamed stays unnamed

How to handle an unnamed prompt

Question they ask. They only named a pattern (sliding window, heap, trees+DP) or said “a logic-heavy question.” There is no title to stamp.

Example. Naina R1 second problem: unnamed. Shiwangi R4: “medium sliding window.” Do not pick LC 3 or LC 76 as “the” question.

Dry run — walk this before you code.

StepWhat you holdResult / why
stay unnamedno LeetCode idChapter 25 is the clue→pattern sheet.
ask 3 thingsinput type, what a legal answer is, nThen name brute + the pattern family.
Job 10454435still none publicYour loop may differ. OA is not a round.

Say out loud. If they only gave a pattern word, open chapter 25. Do not invent the prompt.

No guessed LeetCode ids. Use chapter 25 if they only gave a pattern word.

Description (stay unnamed)WhereWhat you do
logic-heavy non-standard (one hint)Naina UTA R1Stay unnamed. No LC id.
Map+String Amazon Shipping simulationIE.in 2024-grad AUTA mail R1Simulation + maps. No stamp.
easy hashmap / mapsShiwangi UTA R2Unnamed.
medium Sliding WindowShiwangi UTA R4Unnamed. Use ch.25 window card.
one coding with hintsKarun University TA R2Unnamed.
matrix + heapsLC 7280347 R1Unnamed combo.
one relatively easyLC 7623949 R1Unnamed. Same post later Distance K in Fluency.
Trees and DP (told to prep LLD)LC 7981646 R2Unnamed.
Binary Search solved using PQLC 7981646 R3They used a heap on a BS-shaped prompt — say both and pick after the stem.
Heap+HashMap array (LC Medium)Rudraksh hashtag R1Unnamed. Hashtag only.
DP Top 150 variationsRudraksh R2Unnamed.
String / Prefix Sum titlesGFG Apr 2026 selected R1Unnamed titles.
Graph and DP titlesGFG Apr 2026 R2Unnamed titles.
three in-person codingLC 8306214 R1–R3Unnamed. Cloudflare this pass.
count valid BT subsets no two adjacent, empty valid, mod 10^9+7LC 8464858 Class BHouse Robber on a tree, count, not values. Class B unlabeled.
AUTA R1 greedy / tree / leftover puzzleReddit 1ueybmgUnnamed.
AUTA Chennai R1/R2 codingReddit 1qj304zUnnamed.
Divanshu R1 BS medium + sim/stack hard; R2 matrix+mathDivanshu LinkedIn AUTAUnnamed titles.
Arijit LL variation + 1D DPArijit Char AUTA R1Unnamed.
Arijit one SD rest of hourArijit AUTA R2Unnamed SD — ask entities. Not a 10454435 design.
Kamlesh two story string/stack/graphKamlesh OA-as-R1 R1Unnamed.
Rushikesh Graphs/Heaps/Greedy/SW/DP mixedRushikesh mixedUnnamed mix.
LC 6800853 leftover beyond encoded / kth-from-suffix / grid / subtract-digitLC 6800853 AUTA OA-as-R1Titled halves are §1 cards; leftover unnamed.
jumps / max reachable index DPLC 8029194 R2Jump Game family — unnamed exact.
Stone Collision / coins-DP beyond those phrasesLC 6606011 R2Titles in §2; extras unnamed.
Vaishali array two-pointer; DP on triangular matricesVaishali OA-as-R1 YUnnamed exact. Pattern names only.
Job 3100855 Two Pointer / Heap / BSReddit 1s9z862Different Job ID. Pattern names only.
TUF 03 mix of trees and DP; follow-ups unbalanced / memoryTUF 03 BRUnnamed mix.
TUF 08 second graph/OS problem not rememberedTUF 08Unnamed.
TUF 12 hash-table medium-hard; heap brute onlyTUF 12Titles also named above (points on a line / top K).
TUF 13 one DSA after projects — unnamedTUF 13 R4Unnamed.
TUF 19 second coding modified hard + Amazon-internal scenarioTUF 19Unnamed. Do not invent internal APIs.
TUF 203 two medium unnamedTUF 203 R2Unnamed. SDE unspecified file.

5. Intern appendix — not your third live

Same folder / AllQuestion intern rows. Do not treat these as AUTA FTE R3.

QuestionSourceThink / TC note
BFS / Rotten Oranges variationTUF intern 101 liveSame multi-source BFS. INTERN.
Reverse LL in groups of k (variation)TUF 101 liveCount k, reverse group, recurse. O(n)/O(n/k) stack.
Detect loop in a linked list (Floyd)TUF 102 liveslow/fast. O(n)/O(1).
Tree + DP on binary tree (unnamed)TUF 102 liveUnnamed. House Robber III family possible — do not stamp 337.
Asteroid Collision (LC 735 named on intern post)TUF 104 / LC 7124844 liveSame stack as FTE. INTERN — not your third live.
Minimize the Maximum Difference of Pairs (LC 2616 named intern)TUF 104 / HackOn S5BS on answer + greedy adjacent pairs. INTERN.
Validate BST with a twist; topo; unnamed arrayTUF 105 liveUnnamed twists. INTERN.
Graph after two STAR (uncommon for intern, they wrote)TUF 107 liveUnnamed graph. INTERN.
Pacific Atlantic Water FlowAllQuestion Q20 internMulti-source BFS from both oceans. INTERN.
Remove K DigitsDesiQnA Set-61 internMonotonic stack. INTERN — not your third live.
Minimizing Tree Diameter with Path Rewiring CF 2131DDesiQnA Set-61 internCandidate named CF id. DSU was wrong there. INTERN.
Strictly increasing by removing at most oneGFG AUTA internGreedy first descent. INTERN.
Best Time + fee; Reorder Routes to City ZeroGFG intern 2024Stock DP; directed reverse+count. INTERN.
GetRandom O(1); Median stream; LRU; K closest originvarious intern GFGSame templates. INTERN appendix only.
Intern Fluency UNNAMED min-heapLC 7643209Not Distance K. INTERN.
House Robber + HR II; Aggressive Cows variation; Alien dictionaryIE.in intern 2026INTERN. Do not treat as FTE R3.

INTERN — Floyd cycle (detect loop in LL) IE-asked

Question they ask. Detect a cycle in a linked list (Floyd). INTERN TUF 102 — not your FTE third live. Optional: return the cycle start.

Example. 1→2→3→4→2. Cycle at 2. Slow/fast meet inside the cycle.

Dry run — walk this before you code.

StepWhat you holdResult / why
slow+fasts=next, f=next.next. meet ⇒ cycleHashSet of nodes is O(n) extra space.
start of cyclereset one pointer to head; both step 1; meet at entranceOptional follow-up.
INTERNdo not treat as AUTA FTE R3Still the template if they ask it.

Say out loud. Two pointers O(1) space. Intern labeled.

Source: TUF intern 102 live. Not Adarsh’s third live.

Clue → pattern. Detect a cycle → slow+fast. Optional start-of-cycle: reset one pointer to head.

Why this. HashSet of nodes is extra O(n) space. Fast moving 2 vs 1 meets iff a cycle exists.

Brute. HashSet visited. Time O(n). Space O(n). Enumerates nodes into a set.

Optimal. Two ListNode pointers. Time O(n). Space O(1). Beats extra set.

boolean hasCycle(ListNode h) {
  ListNode s = h, f = h;
  while (f != null && f.next != null) {
    s = s.next; f = f.next.next;
    if (s == f) return true;
  }
  return false;
}

INTERN. Do not treat as your R3.

6. Older GFG remainder (2021–23) and pre-2024 dump — compact

Year-out. Not UTA-default. One line each. URLs live in bible §5.A end and Round_2_Question.md.

Title (2021–23 / pre-2024 dump)PatternBruteOptimal
first unique-nationality spectatorhash/queue streamO(n²) rescanO(n) queue+count
parent-child 1-parent nodestree / indegreeO(n²)O(n)
Validate BST variantinorder / boundsO(n²)O(n)
max-bends pathtree DP / DFSexpO(n)
next greater frequencystack + freq mapO(n²)O(n)
minStack one stackencoded pairsO(n) minO(1)
longest palindrome from charsfreq greedyO(n²)O(Σ)
min-length substring covering patternwindow need/haveO(n²)O(n+Σ)
reverse stack via another stacktwo stacksO(n²) naiveO(n)
max water between two buildingstwo pointer / rain variantO(n²)O(n)
north-south bridges LISsort + LISO(n²)O(n log n) patience
LED RGB OOPSOOD—classes + state
rat in a mazebacktrackexpO(3^{mn}) prune
squares-sortsort squares two pointerO(n log n)O(n)
delete leaf value XpostorderO(n²)O(n)
reduce array at most twicegreedy/DP — unnamed exact—ask
closest pair-sumsort + two pointerO(n²)O(n log n)
balanced parentheses combinationsbacktrack / CatalanexpO(C_n · n)
Office Structure OODcomposite tree—ch.06/22
pile of books DSstack / dequeO(n)O(1) ends
Boundary Traversal; BT→DLL; Vertical ordertree BFS/DLL weaveO(n²)O(n)
Sudoku Solver; Paint Housebacktrack / DP house colorsexp / O(n·3²)see dump
Evaluate division; Stepping numbers; Word search 8-dirgraph / BFS digits / backtrack—year-out dump
pairs sum %60freq[60]O(n²)O(n)

7. CS one-liners they actually asked (bible §5.F)

Topic15-second Java-backed answer
Thread vs processProcess = isolated address space; thread = shared heap, own stack. Java Thread / pool. Context switch threads cheaper.
Deadlock4 Coffman: mutex, hold+wait, no preemption, cycle. Fix: lock order, timeout.
HashMapBuckets + treeify at 8; hashCode/equals; load 0.75. Asked after review-word-count.
Why PQGet-min O(log n) vs sort every time. Ropes / Dijkstra / Top K.
B-Tree vs B+B+ keys in leaves + leaf linked → range scans (indexes). B-Tree keys in internal nodes too.
Kafka orderOrder inside a partition, not across. Key → same partition. Do not volunteer a Kafka novel on a two-DSA loop.
REST vs GraphQLResume lists both + ProtoBuf. REST: cacheable resources. GraphQL: client-shaped payload. Only if they ask.
OS: deadlock / memory (IE.in 2025-grad)Same loop as Rate Limiter — OA+3 SD, not UTA two-DSA. Process vs thread; lock order; virtual memory vs OOM.
CN; transactions; Bankers Algo (GFG sde-1-17 last live)TCP vs UDP one line if asked. ACID. Banker’s: deny allocate that is unsafe given max claims. Deadlock Coffman as above.
DNS, MAC vs IP, thrashing (GFG Dec 2020 older)DNS name→IP. MAC link-local; IP routing. Thrashing: paging dominates work. Year-out CS, not UTA-default.
S3 / NoSQL / sharding / Docker / EC2 / REST (IE.in L4 after BR)Ylogx shipped ECS/Docker/ALB/CloudFront — not “I built S3.” Postgres + RLS; do not invent a shard plan. Slot not split on that IE.
core CS UNNAMED (Rohit Jain R2)Unnamed stays unnamed. Do not dump an OS quiz they did not start.

8. LP cheat — scan only. Full spoken STAR is chapter 12. DO NOT SPEAK chapter 13 practice as Adarsh.

How they ask, and a STAR dry run

Question they ask. They name an LP or they do not. Default unnamed pair: Dive Deep then Deliver Results. Situation 15s · Task 10s · Action 40s (three mechanisms) · Result 15s · stop.

Example. Stem: “Tell me about a time you had a tight deadline.” Locked story: Horizon ERC, date fixed, 17th of 80+. Use we for the placement, I for GStreamer / ZED / costmap.

Dry run — walk this before you code.

StepWhat you holdResult / why
S 15sERC 2024, 80+ teams, date does not moveDo not invent a missed ERC.
T 10soccupancy on the costmap was the ship-blockerOne sentence.
A 40sI: 60 FPS GStreamer; ZED 2M+ pts/s; fusion vs extra hardwareThree mechanisms. We: 17th/80+.
R 15s+40% obstacle detection, −55% collision riskWhy-chain next. If they already heard the rover, switch Ylogx 40%/99.9%.

Say out loud. Do not speak chapter 13 as Adarsh. Ylogx has three primaries only. Full STAR is chapter 12.

Scan only. Full spoken STAR is chapter 12. Prompt → talking points is chapter 21. DO NOT SPEAK chapter 13 AS ADARSH.

Resume-derived answers. IE-asked means another candidate heard that stem (bible §5.D or TUF live STAR). Not a Job 10454435 forecast. SDE I intern loop: no reports, no firing, no budget-owner theatre.

Locked spread (do not break)

LPPrimaryBackup
Customer ObsessionGiftedBooksYlogx +65%
OwnershipYlogx RLS + 99.9%Horizon software
Invent and SimplifyIQVIA Hybrid RAGStratifyLabs browser
Are Right, A LotArgus 73%→89%Ylogx measured latency
Learn and Be CuriousIQVIA LangGraphHorizon ROS2
Hire and DevelopIEDC Tech TeamHorizon teammates
Highest StandardsArgus mAP gateYlogx 99.9% / 210ms
Think BigStratifyLabs marketplaceIQVIA 200+ sites
Bias for ActionHorizon ERC datehackathons / Redis ship
FrugalityYlogx Redis −35%Horizon fusion vs hardware
Earn TrustGiftedBooks RAG + 99.5%Ylogx 3-tier RLS
Dive DeepYlogx Redis + RLSIQVIA retrieval
BackboneIQVIA hybrid vs vector-onlyYlogx RLS-in-DB
Deliver ResultsHorizon 17th/80+Ylogx 40% / 99.9%
Earth’s Best EmployerHorizon knowledge sharingIEDC
Success and ScaleArgus 20+ cameras after 89%Ylogx ALB/ECS with RLS

Ylogx has three primaries only (Ownership, Frugality, Dive Deep). IQVIA three (Invent, Learn, Backbone). Argus three (Are Right, Highest Standards, Success and Scale). Horizon three (Bias, Deliver, Earth’s Best). GiftedBooks two (Customer, Earn Trust). Do not promote a backup into a fourth primary.

Default unnamed pair

If they do not name the LP: lead Dive Deep (Ylogx Redis + RLS, not SEO 403) then Deliver Results (Horizon 17th/80+). Third: GiftedBooks doubts hours → 3–10 min.

Dive Deep, 20s. At Ylogx the bot returned rows. I measured bot database latency instead of blaming the model. RLS and RBAC live in Postgres so generated SQL runs as the caller role. Redis cut bot DB latency 35 percent and still had to be the right tier. 99.9 percent uptime, +65 percent analysis, 40 percent faster reports, sub-210 ms dashboards.

Deliver, 20s. Horizon, ERC 2024, 80+ teams, date fixed. I owned GStreamer 60 FPS, ZED 2 more than 2 million points per second, costmap fusion. Stale occupancy was the ship-blocker. 17th of 80+. Obstacle detection +40 percent. Collision risk −55 percent. I will not invent a missed ERC.

STAR clock

Situation 15s · Task 10s · Action 40s (three mechanisms) · Result 15s · stop. They will why-chain. Use I. We only for ERC 17th.

Exact stems from bible §5.D and TUF live STAR

Prompt (as written)LPLocked storyTalking pointsDo not say
Tell me about a time you found an issue in a product and resolved it (even though it wasn’t your task).Ownership / Dive DeepYlogx RLS not only the chatbot demo ticketGenerated SQL as caller role; JOIN-to-other-org nightmare; Redis still RLS; 99.9% / −35%Do not invent a ticket ID. Do not make Ylogx a fourth primary.
Tell me about a time you handled an urgent requirement or made a trade-off decision.Bias / Deliver / FrugalityHorizon ERC date; or Redis vs bigger RDSDate does not move; 60 FPS + costmap; cut extra hardware not isolation; Redis −35% before RDSDo not invent a missed ERC or AWS bill.
Tell me about a time you did something outside of your scope. What was the outcome?Ownership / LearnYlogx isolation on the shared path; or IQVIA LangGraph hopI owned RLS in Postgres; traces as stop; intern, still 99.9%No “I ran the org.” Influence without authority.
Deep dive to find a problem; didn’t know what to do next; tough/critical feedbackDive Deep / Are Right / Earn TrustYlogx latency+RLS; Argus 73% as the feedbackMeasured bot DB not the model; 73% was a fail; 89% + 24 FPS before 20+ camerasNo manager quote. No SEO 403 as Dive Deep lead.
Tell me about a time you handled tasks with a strict deadlineDeliver / BiasHorizon ERC 17th/80+GStreamer 60 FPS; ZED 2M+ pts/s; stale occupancy was the ship-blocker; −55% collisionDo not invent a miss. If they already heard the rover, switch Ylogx 40%/99.9%.
Was there a time when you had to show bias for action?Bias for ActionHorizon ship 60 FPS + costmapDid not wait on extra sensors; fusion vs hardware; date fixedNot Redis as a fourth Ylogx primary.
What’s a task you’re most proud of?Customer or DeliverONE of GiftedBooks 3–10 min or Horizon 17thPick one. RAG on their PDF; or ERC placementDo not dump three projects.
Tell me about a time you had to quickly learn something new.Learn and Be CuriousIQVIA LangGraph + hybrid AzureState machine vs linear chain; hybrid vs vector-only; LangSmith overlap spanDo not invent Qdrant. Resume is Azure AI Search.
Describe a mistake you made. What did you learn?Are Right / Highest Standards / Earn TrustArgus 73% mAP73% misses helmets and fires junk; 15k images; 89% + 24 FPS; then scaleNo invented fight. 73% was not “fine.”
Tell me about a time you faced a significant technical challenge.Invent / Dive DeepIQVIA 200+ page BRDs / ranking contradictionClause IDs cosine misses; hybrid+GraphDB; cite-or-abstain when two high-rank pages disagreeNo extra % beyond resume.
Describe a situation where you had to solve a problem with limited information.Are Right / InventIQVIA first-hit retrieval is false certaintyAgreement + traces; Firecrawl/Bing/DDG/Playwright fail on different sitesDo not invent a sample size.
Tell me about a time you had a conflict with a teammate/manager.BackboneIQVIA hybrid vs vector-only; backup Ylogx RLS-in-DB vs app-onlyDisagree on retrieval. Commit on evals. No interpersonal blow-up on the resume.No invented manager fight.
When you had tough deadlines, and you had to make a compromise, what did you do?Deliver / FrugalityHorizon: cut extra hardware, not the costmap; Ylogx: cache not isolationEarly specific risk: feed late / costmap stale / RLS not in DB yetDo not invent a missed 99.9%.
When you worked out of your designated work?OwnershipYlogx RLS on the path the bot and reports sharedNot “the chatbot ticket only.” Isolation in Postgres.Do not steal Invent onto Ylogx.
A time I went above and beyond for customers; helped teammates/juniorsCustomer / Hire-and-Develop / Earth’s BestGiftedBooks 3–10 min; Horizon pair on launch files; IEDC Tech TeamTheir PDF not a generic corpus; PYQ is analytics; knowledge not in one headNo mentee count. IEDC is not “I was the hiring manager.”
Ownership; working under pressure; learning new technologies (Aditya trio)three LPs — three projectsOwnership Ylogx; pressure Horizon; learn IQVIADo not reuse Ylogx three timesDo not break the spread.
BR: challenge I solved; missing a deadline; problem I identified myself; simplifying a processAre Right / Deliver / InventArgus 73%; Horizon sequence (no invented miss); IQVIA isolation of retrieval; Redis vs RDS / hybrid vs vectorFlag risk early and specificLC 8362604 BR — other loop. Not a forecast.
Tell me about a time you got feedback; faced critical issues; went beyond your taskEarn Trust / Are Right / OwnershipArgus 73%; Ylogx RLS; IQVIA hopLC 6806195 BR mapping in ch.08/12No Haar, no Qdrant.
Complex problem that required in-depth research, POCs, multiple solutions?Invent / LearnIQVIA Deep Research + Hybrid RAG + LangSmithLC 7563011 AUTA HM. 200+ sites; 200+ page BRDs; traces as stopOne scraper is not enough. Do not invent p95.
Last time you deep-dived a bug; last negative feedback; learned something not requiredDive Deep / Are Right / LearnYlogx Redis+RLS; Argus 73%; LangGraph not required for the first scraperGFG 2025 BR (OA-as-R1 loop)Unnamed extras on that BR stay unnamed.
Disagreement with your team / how you handled itBackboneHybrid vs vector-only or RLS-in-DBTUF 02/04 team conflict. Technical conflict only.No fight scene.
Delivered under a tight deadline / prioritized under tight deadlinesDeliver / BiasHorizon ERC; intern TUF 107 presentation deadline is INTERNSequence 60 FPS then costmapDo not invent a miss.
Examples of going above and beyond for customersCustomer ObsessionGiftedBooks hours → 3–10 minTUF 02 R5. Grounded on their PDF.Not Ylogx +65% as the customer lead.
Took full responsibility for a project’s successOwnershipYlogx 3-tier RLS + 99.9%TUF 02 R5.Intern — still I on RLS.
What’s one thing you’re not good at?Earn Trust / LearnHonest intern gap: Java Live Code vs Python/TS internships; or measurement honesty on a % without a baselineTUF 06 BR. Then what you did (this notebook, traces).Do not invent a personality flaw drama. Do not say 73% was fine.
How do you approach learning new technologies?LearnIQVIA LangGraph / Azure hybrid; traces as the stopTUF 06 BR.Not a course-list. Mechanism + eval.
Describe your most challenging projectInvent or DeliverIQVIA 200+ BRDs or Horizon ERC — pick oneTUF 06 BR.Do not mash both into one STAR.
Tell me about a time you helped a teammate succeed.Earth’s Best / Hire-and-DevelopHorizon launch-order pairing; IEDC Tech TeamTUF 13.No mentee count. We only for ERC 17th.
Describe a situation where you missed a deadline. What did you learn?Deliver / Earn TrustDo not invent a miss. Speak flag-risk-early: feed / costmap / RLS.TUF 13; LC 8362604 BR.No missed ERC. No missed 99.9%.
Stepped outside your comfort zone / overcame a significant obstacle / struggled / learned from a mistakeLearn / Bias / Are RightHorizon ROS2/GStreamer; Argus 73%; IQVIA graph hopTUF 14 stems.Map each stem to one locked story. Do not recycle Ylogx four times.
Earning trust and owning up to a mistakeEarn Trust / OwnershipGiftedBooks grounded Q&A; Argus 73% as the miss of a quality barTUF 16.Vocal self-criticism without a fake manager email.
Ownership, handling ambiguous situationsOwnership / InventIQVIA ranking contradiction; Ylogx generated SQL as the caller roleTUF 19 BR; TUF 201 BR named those four LPs.SDE unspecified 201 is not your loop shape.
Tell me about a time you had to do something out of your skill setLearn / BiasHorizon GStreamer/ROS2; intern TUF 107 wording is INTERNSame locked Horizon/IQVIA learnDo not speak intern write-up as autobiography.

Sixteen LPs — 20-second hook

  1. Customer Obsession — GiftedBooks doubts hours → 3–10 min, RAG on their PDF, PYQ analytics.
  2. Ownership — Ylogx three-tier RLS in the database, intern, 99.9% held.
  3. Invent — IQVIA hybrid+graph+test-case gen, not a prompt pile.
  4. Are Right — Argus 73% was a fail; 89% + 24 FPS before twenty cameras.
  5. Learn — LangGraph state, hybrid retrieval, LangSmith pass/fail.
  6. Hire and Develop — IEDC / Horizon sharing launch order. Not a manager. No mentee count.
  7. Highest Standards — same Argus gate.
  8. Think Big — StratifyLabs marketplace + browser inference, −30% iteration.
  9. Bias for Action — ship 60 FPS + costmap, do not wait on extra sensors.
  10. Frugality — Redis −35%, not a bigger RDS first.
  11. Earn Trust — GiftedBooks grounded Q&A; Ylogx isolation.
  12. Dive Deep — latency plus RLS, not SEO.
  13. Backbone — hybrid vs vector-only, then commit on evals.
  14. Deliver Results — Horizon 17th/80+.
  15. Earth’s Best Employer — pair on launch files so knowledge is not in one head.
  16. Success and Scale — do not multiply a 73% model across twenty cameras.

Room checklist

  • Unnamed pair: Ylogx −35% + three tiers; Horizon 17th. Third: GiftedBooks 3–10 min.
  • Aditya trio: three projects (Ylogx / Horizon / IQVIA).
  • Mistake / feedback: Argus 73%.
  • Missed deadline: do not invent. Sequence + early specific risk.
  • Conflict: retrieval or RLS-in-DB. No fight.
  • Why Amazon personal team reason is still something you must prepare — do not invent a team name here.
  • GenAI behavioral: verify, traces, cite-or-abstain. If they paste a tree, code first.

Do not invent missed ERC, missed 99.9%, manager fight, firing, mentee count, AWS bill, p95, TTL, Qdrant, Haar, student headcount, or a Job 10454435 question. Do not copy Exponent / IGotAnOffer sample stories. Do not give Ylogx a fourth primary.

Cross-cuts

PromptLPStoryDo not
DisagreementBackboneHybrid vs vector; backup RLS-in-DBFight scene
Tight deadlineBias / DeliverHorizon ERC date; 60 FPS + costmapInvent a miss. Use we for ERC 17th, not I placed.
Missed deadlineDeliver / OwnershipNo miss on resume — flag occupancy / RLS / 73%Invent miss
Mistake / feedbackAre Right / StandardsArgus 73%→89%Manager quote; Haar
Outside scopeOwnershipYlogx RLS beyond demo ticketFourth Ylogx
Helped teammateHire or Earth’s BestIEDC; Horizon pairingMentee N
Comfort zoneLearn / BiasLangGraph; field vs simFake on-call
Not good atLearn honestJava Live Code vs intern Python/TS; no reportsPerfectionist bit
Learn new techLearnIQVIA LangGraph + hybrid + LangSmithYlogx as LangGraph school
Most challenging projectDeliver or InventHorizon occupancy or IQVIA hybridSix-product tour
Ownership + ambiguityOwnership; Invent/Dive Deep for ambiguityYlogx RLS; IQVIA two pages disagree / Horizon stale occupancy classSDM theatre; Ylogx as a fourth primary