Data Structures & AlgorithmsVery hardTCS NQT · Accenture
Three sorted lists [1, 4, 7], [2, 5, 8] and [3, 6, 9] are merged into one sorted list. What is the value at position 5 (1-based)?
- A. 6
- B. 7
- C. 5
- D. 9
Correct answer: C. 5
The merged list is 1 through 9 in order, so position 5 holds 5. A heap-based merge gives the same result in O(N log k).
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
- A list holds 1, 2, 3, 4, 5. It is rotated right by 2 positions (the last two nodes move to the front). What is the value of the new head…
- How many pairs x < y with 1 <= x, y <= 12 have (x + y) dividing x y exactly?
- How many distinct values does floor(30 / k) take as k ranges over 1 to 30?
- How many triples a < b < c with a, b, c in [1, 10] satisfy a + b = c?
- What is the minimum number of characters that must be deleted from aabbaa so that no two adjacent characters of the remaining string are…
- How many distinct strings can be obtained from aabb by removing exactly one character?