Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the length of the longest substring of "pwwkewbcab" with no repeated characters?
- A. 7
- B. 10
- C. 3
- D. 6
Correct answer: D. 6
Move the left edge past the previous occurrence only when it lies inside the window: the best is 'kewbca', length 6. Counting distinct letters gives 7, 10 is the whole string, and 3 is the classic answer for the 'pwwkew' prefix alone.
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 integers from 1 to 200 inclusive are divisible by 4 or by 6 but not by 12?
- A pancake flip reverses a prefix of length at least 2. What is the minimum number of prefix flips needed to sort [3, 1, 2] into increasing…
- How many non-empty subsets of [1, 2, 3, 4, 6] have a sum divisible by 3?
- How many distinct value-pairs (x, y) with x <= y occur as a[i] + a[j] = 5 for some indices i < j in [1, 1, 2, 2, 3, 3, 4, 5]?
- What is the lexicographically largest substring of length 2 in "zebraqzyx"?
- Numbers 1 to 5 are pushed in order onto a stack, and pops are interleaved so that the output is 4, 3, 5, 2, 1. How many pops are performed…