Data Structures & AlgorithmsModerate

In how many ways can 1 2 2 0 3 2 1 2 2 be cut into exactly THREE non-empty contiguous parts whose sums are all equal? (A cut is a pair of positions.)

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

Correct answer: B. 2

Each part must have sum total/3, so the valid cut positions are the prefix sums equal to total/3 and 2·total/3 with the first cut before the second. Counting two-part splits or forgetting the strict order of the two cuts gives different totals.

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

Exams that ask this topic