Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA
A singly linked list holds 1..7. Using the slow/fast pointer method, the slow pointer reaches the middle node. How many nodes come after the middle node?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
For odd length the middle is the exact centre (node 4), leaving three nodes after it. The slow pointer stops at index 3 of 0-based indexing.
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
- What is the minimum number of elements to delete from [1, 1, 1, 2, 2, 2, 2, 3] so that every value appears at most twice?
- Group the values [1, 2, 4, 5, 6, 9, 10] so that consecutive sorted values with difference at most 1 share a group. How many groups result?
- How many ordered triples of positive integers (x, y, z) satisfy x + y + z = 10?
- Replacing at most one character, what is the length of the longest substring of "abcbbbcaa" that can be made into a single repeated letter?
- What is the smallest integer greater than 13 that has the same number of 1-bits as 13 in binary?
- Convert a(b+c)-d/e to postfix with the shunting-yard algorithm (+ and - have lower precedence than and /; all operators are…