lc567. 字符串的排列
class Solution: def checkInclusion(self, s1: str, s2: str) -> bool: result = False s1_list = sorted(list(s1)) # 滑动窗口值=s1的长度 i = 0 j = i + len(s1) - 1 s2_window_list = None while j < len(s2): s2_window_list = list(s2[i:j + 1]) s2_window_list.sort() k = 0 while k < len(s2_window_list): if s1_list[k] == s2_window_list[k]: k += 1 else: break if k == len(s2_window_list): result = True break i += 1 j += 1 return result
浙公网安备 33010602011771号