Find the Damaged Toy

Problem Overview

  • Determine which kid receives the damaged (last) toy when toys are handed out in a circle.
  • Inputs: N (kids labeled 1..N), T (toys), D (starting kid ID); Output: the ID of the kid who gets the last toy.
  • Distribution proceeds one toy per kid in ascending order, wrapping from N back to 1.
  • Real-world context: birthday party toy distribution; a classic coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: