Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: The sum of the numbers obtained by repeatedly removing the first and last elements of [1, 2, 3, 4, 5, 6, 7, 8] and adding them as a pair, across all rounds (4 rounds), is what value?
- A. 36
- B. 9
- C. 4
- D. 72
Correct answer: A. 36
Each round adds an outer pair summing to 9 (1+8, 2+7, 3+6, 4+5), so 4 × 9 = 36, the total of the array. 9 is one round, 4 counts rounds, and 72 counts each pair twice.
More Coding Interview Problems questions
- Problem: What is the remainder when 2^100 is divided by 9?
- Problem: The sum of all three-digit palindromic numbers (100–999) is what value?
- Problem: How many integers n with 0 ≤ n ≤ 255 have exactly four 1-bits in their binary representation?
- Problem: What is the largest power of 2 that is less than or equal to 1000?
- Problem: Find the smallest positive integer x such that floor(x/2) + x is at least 50.
- Problem: A set of jobs has deadlines and profits: (deadline 1, profit 20), (deadline 2, profit 40), (deadline 2, profit 30), (deadline 3…