Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional
A circular list holds 1..10. Starting at 1, you count 4 nodes (including the current one) and delete the fourth, then continue counting from the next node. Which node is deleted last?
- A. 5
- B. 6
- C. 4
- D. 7
Correct answer: A. 5
Simulate the elimination with an index modulo the remaining length; the last survivor is the last deleted node. Off-by-one in the counting convention moves the answer by one position.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Buildings of heights [3, 7, 8, 3, 6, 1] are viewed from the left. How many buildings are visible (a building is visible if it is strictly…
- Evaluate the postfix expression "3 4 min 5 max 2 +" where min and max take two operands and return the smaller or larger.
- What is the length of the longest contiguous subarray of [2, 0, 0, 2, 0, 2, 2] whose sum is 0?
- How many integers from 1 to 100 inclusive are divisible by none of 2, 3 and 5?
- What is the digital root of the product 9 18 27 34?
- Which string is the longest common prefix of ["flower", "flow", "flight", "flute", "fly"]?