Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE
Problem: Find the length of the shortest substring of "xaybzcxyabc" that contains all the letters a, b and c at least once.
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
A two-pointer window that shrinks while all three letters remain covered finds the minimum window. Choosing the first complete window instead of the smallest one fails.
More Coding Interview Problems questions
- Problem: A Conway's Game of Life grid on a 4×4 board with alive cells at (1,0), (1,1), (1,2), (0,2) is advanced by one generation…
- Problem: A list of 6 customers arrives at a bank counter with service times 4, 1, 3, 2, 6, 5 (in that arrival order). The counter serves…
- Problem: A linked list of 10 nodes is traversed with Floyd's tortoise and hare: the slow pointer moves 1 step and the fast pointer moves 2…
- Problem: An LRU cache holds 3 entries. Keys are accessed in this order: 1, 2, 3, 1, 4, 2, 5, 1, 3, 4. A key is a hit if it is already…
- Problem: Tower of Hanoi with 6 disks, moving all disks from peg A to peg C using peg B as the spare (standard rules). How many moves does…
- Problem: Count the integers from 1 to 999 whose decimal digit sum is divisible by 7.