Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: The array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] is reduced by repeatedly removing the first two elements and appending their sum to the end, until one element remains. What is that element?
- A. 175
- B. 55
- C. 19
- D. 3
Correct answer: B. 55
Each round preserves the total, so the survivor is 1 + … + 10 = 55. 175 adds up all the appended sums, 19 is the sum of the last two originals, and 3 is the first appended value.
More Coding Interview Problems questions
- Problem: For the sequence 2, 3, 5, 7, 11, …, the first 10 prime numbers are listed. What is the sum of the 10th and 7th primes in the list?
- Problem: A bitmask represents a subset of the 4 items {A, B, C, D} by bits 0–3. How many subsets have an even number of items and do NOT…
- Problem: Find the number of ways to select a non-empty subset of {1, 2, 4, 8, 16} whose sum is a multiple of 5.
- Problem: In the array [3, 5, 2, 8, 6, 1], the number of elements that are greater than every element after them (right leaders) is…
- Problem: A monotone sequence is built: start with 1, and append the next number as (previous number) + (number of digits of previous…
- Problem: The numbers 1 to 20 are split into odd numbers and even numbers. What is the absolute difference between the sum of the odd…