Data Structures & AlgorithmsModerate

What is the length of the longest contiguous subarray of 1 2 1 3 3 2 2 4 4 4 4 1 in which EVERY distinct value appears an even number of times?

  1. A. 12
  2. B. 3
  3. C. 10
  4. D. 11

Correct answer: C. 10

Keep a parity bitmask over values: two prefixes with equal masks bracket a block where every value appears an even number of times. Checking only the overall length parity or distinctness tests different conditions.

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

Exams that ask this topic