<jupyter_start><jupyter_text>Permutation in StringGiven two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise.In other words, return true if one of s1's permutations is the substring of s2.<jupyter_code>'''
Example 1:
    s1 = "ab", s2 = "eidbaooo" -> true
Explanation: s2 contains one permutation of s1 ("ba").

Example 2:
    s1 = "ab", s2 = "eidboaoo" -> false
'''

from collections import Counter


def check_inclusion(s1: str, s2: str) -> bool:
    c1 = Counter(list(s1))
    
    left, right = 0, len(s1) - 1
    c2 = Counter(s2[:len(s1)])
    
    
    while right < len(s2):
        if c1 == c2:
            return True
        else:
            left +=1
            right +=1
            c2 = Counter(s2[left: right + 1])
            
    return False

assert check_inclusion('ab', 'eidboaoo') == False
assert check_inclusion('ab', 'eidbaooo') == True<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12095032397408208, 'fraction_numerical': 0.03455723542116631, 'mean_word_length': 2.6785714285714284, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '127861', 'license': 'MIT', 'n_tokens_mistral': 344, 'n_tokens_neox': 321, 'n_words': 102, 'path': 'python-data-structures/interview-fb/permutation-in-string.ipynb', 'repo_name': 'dimastatz/ml-workshop', 'size': '926'}