Data Structures & AlgorithmsHard

Among the contiguous windows of length exactly 3 in 2 4 1 6 3 8 5 10 that contain at most one ODD number, what is the largest window sum?

  1. A. 15
  2. B. 24
  3. C. 23
  4. D. 22

Correct answer: C. 23

Filter the length-3 windows by their odd count first and then take the maximum sum among the survivors. Ignoring the filter, relaxing it to two odd numbers, or using length 2 gives a different answer.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic