Sat for the Flipkart GRiD 8.0 assessment today. Jotting down the approach for each problem while it's fresh, mostly for my own memory but maybe useful if you're prepping for something similar.
Three coding problems, broken down below.
Problem 1: Tree Reconstruction from a Gapped Array
The core challenge
- Given a "modified" array representation of a binary tree
- Null nodes don't reserve array slots for their children
- So the usual 2i / 2i+1 indexing breaks down, array has irregular gaps
My approach
- Treat it as pure deserialization, not index math
- Maintain a queue of "nodes still waiting for children"
- Pop a node, consume the next one or two array slots as its left/right children, skip null markers
- Push any newly created non-null children onto the queue
- Repeat until array is exhausted
Why it works
- A null node never gets pushed to the queue
- So it never consumes further array slots for children it doesn't have
- That's exactly what recreates the gaps
Checking for "nodes with children"
- Trivial once tree is built, just check if left or right pointer is non-null
What tripped me up
- Output order. Expected order was an in-order traversal (left, node, right), not creation order
Takeaway
- "Array representation of a tree" isn't one fixed format, read constraints before assuming standard indexing
Problem 2: SQL Filtering Across a Join Table
The core challenge
- Three tables: trainees, trainers, and a linking table for who attended whose session
- Find trainees who attended at least one session under trainer A, zero sessions under trainer B
My approach
- Double EXISTS / NOT EXISTS pattern
- Check a matching row exists in the join table, joined to trainer A
- Check no matching row exists, joined to trainer B
Why EXISTS over IN
- NOT IN silently breaks if the subquery ever returns a NULL
- NOT EXISTS doesn't have that landmine
What tripped me up
- Column names, guessed at the join table's foreign keys wrong on the first pass
Takeaway
- Half of SQL debugging is confirming you're joining on the field that's actually there
Problem 3: Round-Robin Tournament with Tie-Break Terrain Selection
The core challenge
- Racers ranked independently across three terrains
- For every pair, the terrain used is picked by a layered tie-break rule: best winner rank, then best loser rank, then a fixed terrain priority as final tie-break
My approach
- Straightforward O(n^2) loop over all pairs
- For each pair, evaluate all three terrains
- Keep whichever terrain currently satisfies the tie-break rule best
What tripped me up
- Keeping the tie-break logic clean without turning it into nested if/else per rule
The fix
- Write it as one running "best so far" comparison
- Ordering rules fall out of comparison order instead of needing separate branches
Takeaway
- Multi-level tie-break rules read cleaner as one running comparison than stacked conditionals
Overall Thoughts
- Nothing wildly novel, but good breadth
- Tested whether you can adapt standard patterns (BFS tree building, EXISTS-based filtering, pairwise comparison) to slightly unusual constraints
- Not just pattern-matching a memorized template
Will update if I hear back on results.