Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional
A linked list holds 1, 2, 3, 4, 5, 6, 7. Reversing each complete group of 3 nodes (leaving a final incomplete group unchanged) gives which node order?
- A. 3 2 1 6 5 4 7
- B. 7 6 5 4 3 2 1
- C. 3 2 1 4 5 6 7
- D. 1 2 3 6 5 4 7
Correct answer: A. 3 2 1 6 5 4 7
Reverse each full group of k nodes; the last incomplete group keeps its order. Reversing the entire list is a different operation.
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
- How many integers from 1 to 100 inclusive are divisible by at least one of 3, 5 or 7?
- What is the sum of lcm(a, b) over all unordered pairs of distinct positions in [2, 3, 4, 6]?
- How many non-empty subsequences of [2, 3, 5, 7] have a product strictly less than 50?
- In how many ways can [1, 2, 3, 0, 3] be cut into 3 non-empty contiguous parts such that all three parts have equal sum?
- What is the length of the longest contiguous subarray of [1, 5, 6, 2, 8, 3] whose maximum minus minimum is at most 3?
- Meetings occupy the half-open intervals [s, f) listed as (1,2), (3,4), (0,6), (5,7), (8,9), (5,9). Only one meeting may use the room at a…