Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

In "abccbaxyz", take the longest palindromic substring (the first one if tied) and count its distinct characters.

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

Correct answer: A. 3

The longest palindrome is "abccba" with six characters, but it uses only three distinct letters. Counting positions would give six; distinct letters give three.

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

Exams that ask this topic