Data Structures & AlgorithmsVery hardICPC regional · TCS NQT Digital
Problem: 23 people stand in a circle numbered 1 to 23. Starting at person 1, every second person is eliminated (counting around the circle, so person 2 goes first, then 4, and so on), until one remains. Which person survives?
- A. 15
- B. 14
- C. 13
- D. 7
Correct answer: A. 15
For k = 2 write n = 2^m + L: 23 = 16 + 7, so the survivor is 2L + 1 = 15. Dropping the + 1 gives 14, using n = 22 gives 13, and reporting L itself gives 7.
More Coding Interview Problems questions
- Problem: Eight cards labelled 1 to 8 are in a row. A perfect out-shuffle splits the deck into two equal halves (1–4 and 5–8) and…
- Problem: Lamps 1 to 20 are all off. For each pass i = 1 to 20, every lamp whose number is a multiple of i is toggled. How many lamps are…
- Problem: Count integers from 1 to 100 that are divisible by 3 or by 5 but not by 15.
- Problem: Compute 2^(2^5) mod 1000 (that is, 2 raised to the power 32, taken modulo 1000).
- Problem: With coin denominations 1, 7 and 10, what is the minimum number of coins needed to make 97?
- Problem: Job sequencing: five jobs (deadline, profit) are (2, 100), (1, 19), (2, 27), (1, 25), (3, 15). Each job takes one unit of time…