EASYasked at 1 company

Find the Child Who Has the Ball After K Seconds

A easy-tier problem at 62% community acceptance, tagged with Math, Simulation. Reported in interviews at Agoda and 0 others.

Founder's read

You're at Agoda or another company's assessment and you see a problem about kids passing a ball back and forth for K seconds. It looks like simulation at first glance, but there's a math trick buried inside that makes the obvious loop unnecessary. The problem wants you to figure out which child holds the ball after K passes, given N children standing in a circle and a specific passing pattern. Most candidates waste time coding a full simulation when the pattern repeats predictably. If you hit this live and your first instinct is "loop K times", StealthCoder solves it in seconds by surfacing the underlying math that collapses all that iteration into a single calculation.

Companies asking
1
Difficulty
EASY
Acceptance
62%

Companies that ask "Find the Child Who Has the Ball After K Seconds"

If this hits your live OA

Find the Child Who Has the Ball After K Seconds is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The core insight is that the ball follows a predictable cycle. N children pass the ball back and forth in a line or circle, and the direction reverses at the ends. Instead of simulating each of the K passes, you can use modular arithmetic to jump straight to the final position. The trick is recognizing that position depends on which direction the ball is traveling at any given time, and that direction flips based on how many times the ball has bounced off the ends. Most candidates code the full simulation without realizing the problem is really asking you to detect the cycle length and use modulo to land on the answer. The simulation approach works but costs unnecessary time on a problem that rewards pattern recognition. If you blank on the math during the live assessment, StealthCoder detects the pattern and gives you a working solution immediately.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Find the Child Who Has the Ball After K Seconds recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find the Child Who Has the Ball After K Seconds interview FAQ

Is this really an easy problem or is the acceptance rate misleading?+

The 61.5% acceptance rate is solid for easy tier and reflects that most people get it right, but many take the slow route. The math shortcut isn't obvious if you think "simulation first", but once you spot the cycle, the code is trivial. It's easy in disguise.

Do I actually need to simulate all K seconds?+

No. The ball's position repeats in a cycle. Use modular arithmetic to compute the final position directly. Simulation works but fails on large K values and wastes time. The cycle is the key.

How does the Math topic relate to what looks like a simulation problem?+

The Math comes from recognizing that the ball follows a repeating pattern based on N (number of children) and the direction of travel. Once you know the cycle length, modulo math gives you the answer without looping K times at all.

What's the most common mistake on this problem?+

Coding a full loop that iterates K times and tracks position manually. It's correct but slow and error-prone. The mistake is not seeing that direction reversal happens at predictable intervals, turning the problem into pure math.

Will Agoda or similar companies ask follow-ups about optimization?+

Possibly. If your first solution is simulation, an interviewer might push you to optimize. Having the math approach ready proves you understand the pattern, not just that you can code a loop. Be ready to pivot quickly.

Want the actual problem statement? View "Find the Child Who Has the Ball After K Seconds" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.