Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: The string "xyzzyxzz" is considered. How many of its substrings of length 3 are palindromes (counted by index)?

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

Correct answer: D. 0

Test each length-3 window against its reverse. Palindromes of length 2 (such as 'zz') are excluded by the length requirement.

More Coding Interview Problems questions

Exams that ask this topic