iT邦幫忙

2025 iThome 鐵人賽

DAY 14
2

https://ithelp.ithome.com.tw/upload/images/20250928/20177944dzrPkXeZmF.jpg

class Solution{//O(N)O(1)
public:
    bool checkInclusion(string s1, string s2){
        int m=s1.size(),n=s2.size();if(m>n)return false;
        int cnt[26]={0}, need=m;for(char c:s1)++cnt[c-'a'];
        for(int r=0;r<n;++r){
            if(cnt[s2[r]-'a']-->0)--need;
            if(r>=m && cnt[s2[r-m]-'a']++>=0)++need;
            if(!need)return true;
        }return false;
    }
};

上一篇
第二個周末思考反省一下&下周到辦公室樓下跑個步 雖然未成功過XD
下一篇
I have memorized it 438 && 倒數五天發錢錢XD 久違了整理一下羽球拍的袋子
系列文
轉職仔之Data Science and ai master後的持續精進技術之路17
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

1
AndyAWD
iT邦新手 2 級 ‧ 2025-09-28 21:46:38

快要一半了,快樂~

想到十月十二那附近到底要不要帶電腦出門呢><

我要留言

立即登入留言