Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

What is the length of the longest run of equal consecutive values in [5, 5, 5, 6, 6, 5, 5, 5, 5]?

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

Correct answer: A. 4

Scan once, resetting the run count when the value changes. The run of four 5s at the end is longer than the opening run of three.

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

Exams that ask this topic