Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
How many starting positions in "abcbabcab" match the pattern "abc" with exactly one mismatched character?
- A. 1
- B. 3
- C. 2
- D. 0
Correct answer: D. 0
Count windows with exactly one mismatch by direct comparison; exact-match counting (the last option) ignores the one-mismatch windows entirely.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many substrings of length 2 of "abcba" read the same forwards and backwards?
- A histogram has bar heights [2, 1, 5, 6, 2, 3, 4, 1] (each bar has width 1). What is the area of the largest rectangle that fits entirely…
- What is the sum of the minimum element over every contiguous subarray of [3, 1, 2, 4, 1]? (Every subarray counts, including repeated…
- Sum the maximum of every contiguous window of length 3 in the array [1, 3, -1, -3, 5, 3, 6, 7] (there are n − k + 1 windows). What is the…
- The stock span on day i is the number of consecutive days up to and including day i with price ≤ the price on day i. Prices are [100, 80…
- Bars of heights [4, 2, 0, 3, 2, 5, 1, 0, 3] (width 1 each) hold rainwater between them. How many units of water are trapped in total?