Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: Count the palindromic substrings of length exactly 4 in the string "aabbaabbaa".
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
Test each length-4 window against its reverse. Including windows of other lengths, or counting only distinct strings, gives a different number.
More Coding Interview Problems questions
- Problem: How many distinct two-letter substrings does "mississippi" contain?
- Problem: The smallest period of a string s is the least p ≥ 1 such that s[i] = s[i+p] for all valid i. What is the smallest period of…
- Problem: What is the length of the longest proper border (a proper prefix that is also a suffix) of "abacabacaba"? A proper border is…
- Problem: How many runs (maximal blocks of equal consecutive characters) does "aabbbaaaacc" contain?
- Problem: Houses are arranged in a circle with values [2, 3, 2, 5, 1]. You may rob any set of houses with no two adjacent in the circle…
- Problem: Count the subsets of [3, 1, 4, 2, 6, 4] whose sum is exactly half the total sum (the subset may be any size; the empty subset is…