Skip to content

Commit 8f65d1f

Browse files
committed
#76: description update
1 parent b29c9b5 commit 8f65d1f

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

c-sharp/Problems/sliding-window/MinimumWindowSubstring.cs

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,56 @@
11
/**
22
* 76
33
* Minimum Window Substring
4-
**
4+
**
55
* Given two strings s and t of lengths m and n respectively,
6-
* return the minimum window substring of s
7-
* such that every character in t (including duplicates) is included in the window.
8-
*
6+
* return the minimum window substring of s such that
7+
* every character in t (including duplicates) is included in the window.
98
* If there is no such substring, return the empty string "".
10-
*
9+
*
1110
* The testcases will be generated such that the answer is unique.
12-
*
13-
* Follow up: Could you find an algorithm that runs in O(m + n) time?
14-
*
11+
*
12+
* Example 1:
13+
* Input: s = "ADOBECODEBANC", t = "ABC"
14+
* Output: "BANC"
15+
* Explanation: The minimum window substring "BANC" includes 'A', 'B', and 'C' from string t.
16+
*
17+
* Example 2:
18+
* Input: s = "a", t = "a"
19+
* Output: "a"
20+
* Explanation: The entire string s is the minimum window.
21+
*
22+
* Example 3:
23+
* Input: s = "a", t = "aa"
24+
* Output: ""
25+
* Explanation:
26+
* Both 'a's from t must be included in the window.
27+
* Since the largest window of s only has one 'a', return empty string.
28+
*
29+
* Constraints:
30+
* • m == s.length
31+
* • n == t.length
32+
* • 1 <= m, n <= 10^5
33+
* • s and t consist of uppercase and lowercase English letters.
34+
*
35+
* Follow up:
36+
* Could you find an algorithm that runs in O(m + n) time?
37+
*
38+
* Hint 1:
39+
* Use two pointers to create a window of letters in s, which would have all the characters from t.
40+
*
41+
* Hint 2:
42+
* Expand the right pointer until all the characters of t are covered.
43+
*
44+
* Hint 3:
45+
* Once all the characters are covered,
46+
* move the left pointer and ensure that
47+
* all the characters are still covered to minimize the subarray size.
48+
*
49+
* Hint 4:
50+
* Continue expanding the right and left pointers until you reach the end of s.
51+
**
1552
* https://leetcode.com/problems/minimum-window-substring/
16-
*/
53+
***/
1754

1855
using System.Collections.Generic;
1956

0 commit comments

Comments
 (0)