ProgrammingHardTCS NQT · Infosys
What is the largest sum of any three consecutive elements of {2, 1, 5, 1, 3, 2}?
- A. 8
- B. 9
- C. 7
- D. 6
Correct answer: B. 9
The window sums are 8, 7, 9 and 6, and the largest is 9. A fixed-size sliding window updates each sum by one addition and one subtraction.
More C Programming questions
- The sorted array is {1, 3, 6, 6, 8}. What is the index of the first occurrence of 6?
- How many integers in the range 0 to 15 have an even number of 1 bits in binary?
- How many 1 bits are set in 2^20 - 1 (a 32-bit unsigned value)?
- uint8t a = 16; a = a a; What is a?
- uint32t t = 2000000000u + 2000000000u; What is t?
- char buf[10]; char a = buf + 2, b = buf + 9; What does printf("%td", b - a) print?