Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: The string "racecar" has length 7. How many of its substrings are palindromes with length at least 3? Count index ranges.

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

Correct answer: A. 3

Each index range of length at least 3 is tested against its reverse. Counting only the maximal palindromes (not their inner palindromes) gives a smaller count.

More Coding Interview Problems questions

Exams that ask this topic