Reported May 2024
Motivesimulation

Chunked Round-Robin Row Traversal

Reported by candidates from Motive's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Motive OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Motive OA, reported in May 2024, is treating it like a plain matrix walk and forgetting that rows run out at different times. Chunked Round-Robin Row Traversal looks easy, and it is, until an empty row or a short row breaks your loop. The hinted tag says tree, but nothing here is a tree. It's array simulation with per-row pointers. If you blank on the loop structure during the live assessment, StealthCoder runs invisibly as a safety net and hands you a working solution.

The problem

Given a jagged matrix rows and a positive chunkSize, visit active rows in their original order. On each visit, append up to chunkSize remaining values from that row. Continue cycling until every row is exhausted, and return the traversal.

Function
roundRobinRows(rows: int[][], chunkSize: int) → int[]

Examples
Example 1
rows = [[1,2,3,4],[5,6],[7,8,9],[10]]
chunkSize = 2
return = [1,2,5,6,7,8,10,3,4,9]
Example 2
rows = [[],[1,2],[3]]
chunkSize = 1
return = [1,3,2]

Constraints
0 <= rows.length <= 1000.
The total number of values is at most 100000.
1 <= chunkSize <= 100000.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Keep one index per row, all starting at zero. Loop in passes. In each pass, go through rows in original order, and for each row with remaining values, copy min(chunkSize, remaining) values and advance its pointer. Stop when a full pass copies nothing, or when the output length equals the total count. Check Example 1: pass one gives 1,2,5,6,7,8,10, pass two gives 3,4,9. The common pitfall is skipping empty rows wrongly or looping forever because you never detect completion. Another is rebuilding lists by slicing, which costs extra time. Pointers keep it O(total values plus passes times rows). With 1000 rows and 100000 values, that's fine. If the loop logic slips under pressure, StealthCoder is the hedge on the live OA, reading the prompt and giving you the pointer-based version.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Chunked Round-Robin Row Traversal cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Motive's OA.

Motive reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Chunked Round-Robin Row Traversal FAQ

How hard is Chunked Round-Robin Row Traversal really?+

Easy to medium. There's no clever algorithm, just careful simulation. The risk is edge cases like empty rows, rows shorter than chunkSize, and a chunkSize bigger than every row. If you handle those, it's a ten-minute problem.

What's the trick to solving it?+

Track a pointer per row and run repeated passes over the rows in original order. Each visit takes min(chunkSize, remaining) values. Stop once all pointers reach the end of their rows. No sorting or fancy structures needed.

Is this really a tree problem like the hint says?+

No. The tree hint doesn't match the problem text. You're given a jagged array of arrays and simulating a cyclic read. Treat it as array simulation with index pointers, and don't waste time looking for tree traversal.

What edge cases should I test?+

Test an empty rows list, which should return an empty array. Test empty inner rows like Example 2. Test a chunkSize larger than every row. Also test a single long row with many small chunks, to confirm your termination condition works.

How do I prepare for this in 48 hours?+

Write the pointer-based simulation from scratch twice, using both examples. Then trace the termination logic by hand. Focus on jagged array handling and loop exits, since that's where first attempts fail. Expect similar simulation questions from Motive.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Motive.

OA at Motive?
Invisible during screen share
Get it