Data Structures & AlgorithmsHardTCS NQT · Accenture
Reverse the sublist between positions 3 and 6 (1-based, inclusive) of the list 1, 2, 3, 4, 5, 6, 7, 8. What value is at position 4 of the result?
- A. 6
- B. 4
- C. 5
- D. 7
Correct answer: C. 5
Reversing positions 3 to 6 gives 1, 2, 6, 5, 4, 3, 7, 8, so position 4 holds 5. Reversing the wrong span shifts the answer.
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
- Rotate the list 1, 2, 3, 4, 5, 6, 7 to the right by 10 positions (each rotation moves the last node to the front). What value is at the…
- Stable partition of the list [1, 4, 3, 2, 5, 2] around x = 4 puts every node with value < 4 first, then every node with value >= 4…
- Asteroids move in a row; positive values move right and negative values move left, and when two meet the one with the smaller absolute…
- Daily temperatures are 73, 74, 75, 71, 69, 72, 76, 73. For each day, the wait is the number of days until a warmer day (0 if none). What…
- An array [2, 3, 1, 1, 4] gives the maximum forward jump from each index. Starting at index 0, what is the minimum number of jumps needed…
- There are 100 bulbs, all off. For each i from 1 to 100, pass i toggles every bulb whose number is a multiple of i. How many bulbs are on…