Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: How many palindromic substrings of even length does "abbaccdd" contain?
- A. 5
- B. 4
- C. 3
- D. 6
Correct answer: B. 4
Even-length substrings have an even number of characters, so the loop steps by two. Counting odd-length palindromes by mistake changes the total.
More Coding Interview Problems questions
- Problem: The string "aaaa" can be written as a concatenation of the pieces "a" and "aa" in several ways (order matters). How many such…
- Problem: The minimum ASCII delete sum to make the strings "sea" and "eat" equal is the least total ASCII value of deleted characters. Give…
- Problem: A pattern-matching task uses the string "abxcabcyabd" and the target "abc". How many length-3 windows of the text differ from…
- Problem: Using shell-style wildcards ( matches any run of characters including empty, ? matches exactly one character), how many words in…
- Problem: Choose a subsequence of [2, 3, 5, 7, 8] with no two chosen elements at adjacent positions. How many such non-empty choices sum to…
- Problem: The egg-dropping puzzle with 2 eggs and a 10-floor building: what is the minimum number of drops needed in the worst case to find…