Solving the coding problem: Minimum Window Substring (Leetcode 76)
4 min readOct 8, 2020
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
Example:
Input: S = "ADOBECODEBANC", T = "ABC"
Output: "BANC"
I found interesting non-standard approach using just one pointer, which can solve that problem in O(N + M) time and O(M) space where N size of S and M size of T.
Idea is simply based on the fact that we can maintain position of each char at T and update it…