Shortest substring with N distinct characters

0
Remix

Given a string and a number n, return the shortest substring that contains n distinct letters (or say that none exists). Use a sliding window that grows until it holds n distinct letters and then shrinks from the left. The round gave about twenty minutes for it.

MetaCodingLast asked Oct 2025
No answer yet. Write the first one; the best answer gets endorsed.