Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool checkInclusion(string s1, string s2) {
- int map[26] = {0};
- int left, right, count;
- count = s1.length();
- for(char c: s1) map[c-'a']++;
- for(left=0, right=0; right<s2.length(); right++){
- if(map[s2[right]-'a']-- > 0) count--;
- if(right-left+1 > s1.length()){
- if(map[s2[left++]-'a']++ >= 0) count++;
- }
- if(!count) return true;
- }
- return false;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement