Data Structures & AlgorithmsHardTCS NQT · Product Company SDE
Problem: In the string "aabcbcdbca", what is the length of the shortest substring that contains exactly 3 distinct letters?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
Among substrings with exactly three distinct letters, the shortest is found by checking all index ranges. Finding the longest substring with three letters is a different question.
More Coding Interview Problems questions
- Problem: What is the length of the longest palindromic substring of "abcbxa" that can be made a palindrome after deleting at most one…
- Problem: How many sequences made of the numbers 1 and 2 sum to 8, where no two 2s are adjacent (order matters)?
- Problem: From the array [−10, −10, 5, 2], pick three numbers (distinct positions) to maximise their product. What is the maximum product?
- Problem: The edit distance (insert, delete, replace, each cost 1) between "horse" and "ros" is computed. What is it?
- Problem: What is the length of the longest common subsequence of the three strings "abc", "abd" and "ab"?
- Problem: Split the array [7, 2, 5, 10, 8] into 2 contiguous non-empty parts so that the largest part sum is as small as possible. What is…