标签:== col win ++ ret ems string style http
https://leetcode.com/problems/minimum-window-substring/description/
class Solution { public: string minWindow(string s, string t) { vector<int> v(256, 0); for (auto c : t) v[c]++; int cnt = t.length(); int w = 0; int minw_start = 0, minw_size = INT_MAX; for (int i = 0; i < s.length(); i++) { if (v[s[i]]-- > 0) cnt--; while (cnt == 0) { if (i - w + 1 < minw_size) { minw_size = i - w + 1; minw_start = w; } if (v[s[w]]++ >= 0) cnt++; w++; } } return minw_size == INT_MAX ? "" : s.substr(minw_start, minw_size); } };
标签:== col win ++ ret ems string style http
原文地址:https://www.cnblogs.com/JTechRoad/p/9060316.html