Data Structures & AlgorithmsHardCodeforces Div2 B · TCS NQT
What is the length of the longest substring of "pwwkewfabcdbbca" with no repeated character?
- A. 9
- B. 15
- C. 3
- D. 8
Correct answer: D. 8
Move the left edge past the previous occurrence of the incoming character: the best window is 'kewfabcd' of length 8. Counting distinct letters overall gives 9, 15 is the whole string, and 3 is the answer to the classic '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 DISTINCT substrings (by content, non-empty) does "abcab" have?
- A polynomial hash is H(s) = (Σ ord(s[i]) · B^(n−1−i)) mod M, computed left to right as h = (h·B + ord(c)) mod M, with B = 31 and M =…
- How many DISTINCT palindromic substrings (by content, length at least 1) does "abaaba" have?
- Let t = "ABCC" (its letters may repeat). What is the length of the shortest substring of "ADOBECODEBANCXY" that contains every letter of t…
- Among all cyclic rotations of "bcabca" (there are n = 6 of them, including the original), what is the 0-based index i of the…
- What is the minimum number of characters that must be inserted at the FRONT of "abaccabb" to make the whole string a palindrome?