coding (1) 썸네일형 리스트형 [Leetcode] Longest Substring Without Repeating Characters (python) python class Solution: def lengthOfLongestSubstring(self, s: str) -> int: if not s: return 0 answer = 1 max_num = len(set(s)) n = len(list(s)) for group_size in range(2,max_num+1): for start_idx in range(0,n-group_size+1): if len(set(s[start_idx:start_idx+group_size])) == group_size: answer = group_size break return answer그냥 brute force로 다 구했다. dynamic programming 형식으로 우선 group_size는 logN의 사이즈이고.. 이전 1 다음