Data Structures & AlgorithmsHardTCS NQT · Product Company SDE
Problem: The string "racecarxyz" is examined for palindromic substrings of length at least 5. How many such palindromic substrings are there?
- A. 3
- B. 1
- C. 2
- D. 4
Correct answer: C. 2
Check all index ranges of length at least five. 'racecar' and its inner palindrome 'aceca' qualify, while 'cec' is too short to count.
More Coding Interview Problems questions
- Problem: The number of ways to arrange the letters of "LEVEL" so that the two E's are not adjacent is what value?
- Problem: Consider the sequence 1, 4, 9, 16, … of perfect squares. What is the smallest square that is greater than 500 and also ends in…
- Problem: How many 4-letter strings over {A, B, C} have no letter appearing more than twice?
- Problem: The binary tree with root 10, left child 5, right child 15, and 5 having right child 7, 15 having left child 12, is traversed in…
- Problem: A list starts as [8, 3, 5]. Three insertion steps add the numbers 4, 9, 1 at the front of the list (each is inserted at index 0)…
- Problem: A deque starts as [2, 4, 6]. The operations are: push front 1, push back 8, pop front, push back 3. What is the sum of the final…