Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: In the string "abciiidef", what is the maximum number of vowels (a, e, i, o, u) in any contiguous substring of length 4?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
A fixed-size sliding window tracks the vowel count as it moves; the maximum over windows is the answer. Counting vowels across the whole string gives a much larger number.
More Coding Interview Problems questions
- Problem: What is the minimum number of insertions plus deletions needed to convert "heap" into "pea" if only insertions and deletions are…
- Problem: How many binary strings of length 8 have no two consecutive 1s and begin with the digit 0?
- Problem: A 0/1 knapsack has capacity 10 and items (weight, value): (5, 10), (4, 40), (6, 30), (3, 50). What is the maximum total value?
- Problem: The longest bitonic subsequence (first strictly increasing, then strictly decreasing, either part may be empty) of [1, 11, 2, 10…
- Problem: Find the minimum path sum from the top to the bottom of the triangle [[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]], moving to an…
- Problem: The message "2261" is decoded by mapping 1→A, ..., 26→Z. Each decoding splits the digits into groups of one or two digits, each…