Leetcode.76 Minimum Window Substring (Java)

2021-04-02 16:26

阅读:533

标签:etc   The   lex   while   unique   nta   imu   nim   complex   

Leetcode.76 Minimum Window Substring

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"

Note:

  • If there is no such window in S that covers all characters in T, return the empty string "".
  • If there is such window, you are guaranteed that there will always be only one unique minimum window in S.

Solution

class Solution {
    public String minWindow(String s, String t) {
        int sl = s.length();
        int tl = t.length();
        if(sl == 0 || tl == 0 || sl = 0){
                co ++;
            }
            // 当找到substring需要夹逼找到最短的字串
            if(co == tl){
                while(freq[s.charAt(l)]

Leetcode.76 Minimum Window Substring (Java)

标签:etc   The   lex   while   unique   nta   imu   nim   complex   

原文地址:https://www.cnblogs.com/xm08030623/p/13475945.html


评论


亲,登录后才可以留言!