Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: The string "aaabbcccc" has its runs counted. What is the length of the longest run of identical characters?

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

Correct answer: D. 4

Runs are maximal blocks of identical consecutive characters; the longest here is the block of four c's. Counting distinct letters would give a different answer.

More Coding Interview Problems questions

Exams that ask this topic