Problem · Math

Find the Damaged Toy

Learn this problem
EasyGoldman Sachs logoGoldman SachsOA

Problem statement

At a birthday party, N kids (IDs from 1 to N) sit in a circle. The host has T toys to distribute, starting from kid with ID D and giving one toy at a time in ascending order. After reaching kid N, the count continues from kid 1.

Input

Three integers:

  1. N: Number of kids
  2. T: Number of toys
  3. D: Starting kid's ID

Output

Print the ID of the kid who receives the damaged (last) toy.

Function

findDamagedToy(N: int, T: int, D: int) → int

Examples

Example 1

N = 5T = 2D = 1return = 2
:)

More Goldman Sachs problems

drafts saved locally
public int findDamagedToy(int N, int T, int D) {
    // write your code here
}
N5
T2
D1
expected2
checking account