전체 글 (87) 썸네일형 리스트형 Permute Practice def permute(txt, src): if src == len(txt): return ["".join(txt)] seen = set() result = [] for i in range(src, len(txt)): if txt[i] in seen: continue seen.add(txt[i]) if src!=i: txt[src], txt[i] = txt[i], txt[src] result.extend(permute(txt, src+1)) if src!=i: txt[src], txt[i] = txt[i], txt[src] return result result = permute(lits(digits), 0) - Bas.. [LeetCode] 198. House Robber 198. House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night.Given an integer array nums representing th.. [LeetCode] 1137. N-th Tribonacci Number 1137. N-th Tribonacci NumberThe Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0.Given n, return the value of Tn. My Codeclass Solution: def tribonacci(self, n: int) -> int: if n Improvedclass Solution: def tribonacci(self, n: int) -> int: if n==0: return 0 elif n==1 or n==2: return 1 .. 이전 1 2 3 4 5 ··· 29 다음 목록 더보기