Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: In the string "xyxyxy", how many substrings of length 4 are palindromes?
- A. 1
- B. 0
- C. 2
- D. 3
Correct answer: B. 0
Every length-4 window of an alternating string starts and ends with different letters (x...y or y...x), so none is a palindrome and the count is zero.
More Coding Interview Problems questions
- Problem: A sequence of 10 operations applies to an initial value of 0: operation i (1 ≤ i ≤ 10) adds i if i is odd and multiplies the…
- Problem: A graph's adjacency list is 0: [1, 2], 1: [3], 2: [3, 4], 3: [5], 4: [5], 5: []. What is the number of distinct topological…
- Problem: The number of integers from 1 to 100 that have exactly three divisors is what value? (Numbers with exactly three divisors are…
- Problem: What is the number of inversions in the array [4, 3, 2, 1, 0]?
- Problem: The string "cabbage" is sorted by letter using a stable sort on the letters only. What is the 4th character of the sorted string?
- Problem: Starting with 1, the operations are: multiply by 2, then add 3, applied three times in a row (x → 2x + 3). What is the result…