Data Structures & AlgorithmsHard

How many contiguous subarrays of 2 7 1 8 2 8 of length at least 2 have a sum that leaves remainder 1 when divided by 4?

  1. A. 3
  2. B. 2
  3. C. 4
  4. D. 1

Correct answer: B. 2

Remainder 1 on division by 4 is tested with the modulus directly on each block's sum, restricted to blocks of length two or more. Dropping the length rule, using remainder 3, or remainder 0 each change the set.

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

Exams that ask this topic