Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

What is the lexicographically largest substring of length 2 in "zebraqzyx"?

  1. A. zy
  2. B. zb
  3. C. ze
  4. D. zr

Correct answer: A. zy

Compare all length-2 substrings lexicographically; the largest is the one with the greatest first character, then the greatest second. Comparing character codes of single letters only is a different question.

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

Exams that ask this topic