Back to problems

Minimum Length Substring

Algorithm · LinkedIn · Medium

You are given two strings s and t. Find the shortest contiguous segment (substring) of s such that all characters of t are present in that segment with at least the required frequencies. In other words, the number of occurrences of each character in the chosen substring must be at least as many as its count in t. If more than one such substring has the same minimal length, you may return any one of them. Return an empty string when no segment of s meets this condition. Keep…

Checking your access…