Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: In the string "dvdf", what is the length of the longest substring with all distinct characters?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
The longest run of distinct characters is 'vdf', of length three; the full string repeats 'd' and so is not valid.
More Coding Interview Problems questions
- Problem: The number of ways to tile a 1×4 strip completely using tiles of length 1 and length 2 (tiles of the same length are…
- Problem: In the binary string "0011100", what is the length of the longest contiguous substring that contains equal numbers of 0s and 1s?
- Problem: How many strings of length 3 over the alphabet {a, b, c} contain no two consecutive a's?
- Problem: The number of subsets of {1, 2, 3, 4} whose elements sum to exactly 5 (the empty set is excluded) is what value?
- Problem: The number of ways to make 15 using coins of values 2, 3 and 5, where the order of coins does not matter, is what value?
- Problem: The sum of the numbers obtained by repeatedly removing the first and last elements of [1, 2, 3, 4, 5, 6, 7, 8] and adding them as…