Data Structures & AlgorithmsHardTCS NQT · Accenture
A list holds 1, 1, 2, 2, 2, 3, 1, 1. Consecutive duplicates are merged into one node each. What is the sum of the values left in the list?
- A. 7
- B. 8
- C. 9
- D. 11
Correct answer: A. 7
The merged list is 1, 2, 3, 1 with sum 7. Removing all copies of a value (not just consecutive ones) would give a different list.
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 distinct strings can be obtained from abc by swapping two adjacent characters at most once (including the original string)?
- A passenger count changes by +3, -1, +2, -2, +4, -3 at successive stops, starting from 0. What is the maximum number of passengers on…
- How many integers x in [1, 500] have digit sum equal to 10?
- How many unordered pairs {a, b} with a < b and 1 <= a, b <= 30 have a b a perfect square?
- An array is [1, 2, 1, 2, 1, 2] (indices 0 to 5). How many pairs of even-indexed positions i < j hold equal values?
- What is the sum of all proper divisors of 220 (divisors less than 220)?