看板 Marginalman
原本還想說sliding怎麼滑== 靠北寫完才想到這window size是固定的 最簡單的那種滑== 我好爛== def checkInclusion(self, s1: str, s2: str) -> bool: cnt_s1 = [0 for _ in range(26)] for c in s1: cnt_s1[ord(c)-ord('a')] += 1 cnt_cur = [0 for _ in range(26)] st = set() st.add(tuple(cnt_cur)) for c in s2: cnt_cur[ord(c)-ord('a')] += 1 cnt_sub = [n_cur-n_s1 for n_cur,n_s1 in zip(cnt_cur,cnt_s1)] if tuple(cnt_sub) in st: return True st.add(tuple(cnt_cur)) return False -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.228.146.144 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1728097297.A.691.html
rainkaras: 窗滑大師 10/05 11:19