Company: Goldman sachs_25july
Difficulty: medium
Birthday party and return gift Problem Description A birthday party was attended by N kids, and each kid was given a unique ID from 1 to N. As a return gift, there are T toys that must be given to the kids. The party host sits the kids down in a circle, ordered by ascending ID, so that kid N is followed by kid 1. Starting with a chosen kid D (between 1 and N), the host hands out one toy at a time to each sequentially numbered kid until all T toys are distributed. Kid D receives the first toy. For example, if the host picks D = 2, the gift distribution order is 2, 3, 4, ..., N-1, N, 1, 2, 3, 4, ... until all T toys are distributed. The very last toy is damaged. Find and display the ID of the kid who receives the damaged (last) toy, so that kid can be told to exchange it at the shop. Complete the function findDamagedToy(N, T, D) , which returns the ID of the kid who receives the last toy. Input Format Three integers, each on its own line, in this order: N: the number of kids T: the numbe