Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: A game uses 5 players in a circle numbered 1 to 5. The player with the ball passes it 3 positions clockwise each turn (the ball moves from the current player to the player three steps ahead). Starting with player 1, after 12 passes, which player holds the ball?
- A. 3
- B. 1
- C. 2
- D. 4
Correct answer: C. 2
Each pass advances the holder by three positions modulo the circle size. Counting 12 passes as moving 12 positions without wrapping gives a different player.
More Coding Interview Problems questions
- What does this program print? python a = [4, 1, 3, 2] best = 0 for i in range(len(a)): for j in range(i + 1, len(a) + 1): best = max(best…
- What does this program print? python n = 6 dp = [0] (1 << n) dp[0] = 1 for mask in range(1 << n): if dp[mask] == 0: continue for v in…
- What does this program print? python x = 22 cnt = 0 while x: x &= x - 1 cnt += 1 print(cnt, bin(22).count('1'))
- Array [2, 7, 4, 9, 5, 8]. What is the largest sum of a contiguous subarray having at most 3 elements?
- Points (0,0), (1,2), (2,1), (3,3), (4,0) in the plane. How many unordered pairs have Manhattan distance exactly 3?
- Four sets {1,2,3}, {2,4}, {3,4,5}, {1,5} are given. How many non-empty sub-collections of these sets have a union equal to {1, 2, 3, 4, 5}?