Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Count the indices i of the string "abacaba" for which the suffix s[i:] is a palindrome.

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

Correct answer: C. 3

Test each suffix against its reverse, including the single-character suffix at the last index. Testing the prefixes instead gives a different count.

More Coding Interview Problems questions

Exams that ask this topic