Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: A string is formed by writing the letters of "kayak" then "level" then "rotor". How many substrings of length 5 of "kayaklevelrotor" are palindromes?
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
Each window is compared with its reverse. The palindromic windows of length 5 are kayak, level and rotor.
More Coding Interview Problems questions
- Problem: Starting from the string "00000" of five zeros, operations flip a substring: each operation chooses positions l ≤ r and flips…
- Problem: The number of ways to choose 3 vertices from a graph's vertex set of size n = 12 such that no two chosen vertices are adjacent in…
- Problem: A stream of 12 numbers 5, 1, 4, 4, 2, 5, 3, 1, 2, 3, 3, 4 arrives. How many distinct values appear at least twice in the stream?
- Problem: Start with x = 5. Repeat this rule: if x is odd, set x = x + 3; if x is even, set x = 2x − 1. Count how many times the rule is…
- Problem: Starting from 0 on a number line, a frog jumps +4, then −1, then +4, then −1 and so on, alternating, for 25 jumps in total. It…
- Problem: Count the vertices of the tree with edges 0–1, 0–2, 1–3, 1–4, 2–5, 5–6, 5–7 whose removal leaves every remaining connected…