Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many contiguous subarrays of [1, 2, 3, 4] have a sum that is a perfect square?

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

Correct answer: D. 3

Enumerate all ten subarrays and test each sum for being a perfect square.

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

Exams that ask this topic