Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: A string is formed by writing the letters of "kayak" then "level" then "rotor". How many substrings of length 5 of "kayaklevelrotor" are palindromes?

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

Correct answer: A. 3

Each window is compared with its reverse. The palindromic windows of length 5 are kayak, level and rotor.

More Coding Interview Problems questions

Exams that ask this topic