Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: Count the palindromic substrings of "abcbaabc" that start at index 0 (each prefix that is a palindrome counts once).
- A. 2
- B. 3
- C. 1
- D. 4
Correct answer: A. 2
Only prefixes of the string are tested, one per end index. Counting palindromes anywhere in the string answers a different question.
More Coding Interview Problems questions
- Problem: Maximum sum of a subarray with length exactly 3 in [4, −2, 5, 1, 0, 2, −3, 6]. Report the maximum window sum.
- Problem: The longest subarray with sum divisible by 4 in [5, 3, 7, 2, 2, 6, 1, 1]: what is its length?
- Problem: In the array [9, 3, 7, 3, 9, 1, 7], how many elements are equal to the maximum of the elements to their right (the last element…
- Problem: Start with the empty stack. Process the string "7 3 2 + 5 -" as postfix tokens (numbers are pushed, operators pop two values…
- Problem: The circular array [3, 1, 4, 2] has a 'next' pointer from each index i to (i+1) mod 4. Starting at index 0 and jumping by the…
- Problem: A stack of plates is filled by pushing 1 to 6 in order and popping after each push whenever the top is even. The final stack…