Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: The array [1, 2, 3, 4, 5, 6, 7, 8, 9] is split into 3 consecutive groups of equal length. What is the sum of the middle group?
- A. 6
- B. 15
- C. 24
- D. 45
Correct answer: B. 15
Groups are [1,2,3], [4,5,6], [7,8,9], so the middle sum is 15. The first group sums to 6, the last to 24, and 45 is the whole array.
More Coding Interview Problems questions
- Problem: The product of the numbers from 1 to 10, divided by the product of the numbers from 1 to 7, is what value?
- Problem: A string is "xoxoxox". How many substrings of length 3 are equal to "xox"?
- Problem: Consider the graph on vertices 1–6 with edges 1-2, 2-3, 3-4, 4-1, 5-6. What is the size of its largest connected component?
- Problem: Starting at index 0 of the array [2, 4, 1, 6, 3], repeatedly jump forward by the value at the current index (no wraparound; the…
- Problem: How many integers in the range 1 to 100 are both a multiple of 3 and have a digit sum equal to 6?
- Problem: The string "abcdefg" is rotated right by 3 positions. What is the first character of the rotated string?