class Solution: def longestSquareStreak(self, nums: List[int]) -> int: check = {num : 0 for num in nums} def root(n): if check[n] != 0: return check[n] y = isqrt(n) if y in check and y * y == n: x = root(isqrt(n)) if x == -1: check[n] = 2 else: check[n] = x + 1 return check[n] check[n] = -1 return -1 ans = -1 for num in nums: if root(num) > ans: ans = check[num] return ans탑다운 DP로 풀었는데, 이 방법이 젤 쉽지 않을까 싶다
댓글 영역
획득법
① NFT 발행
작성한 게시물을 NFT로 발행하면 일주일 동안 사용할 수 있습니다. (최초 1회)
② NFT 구매
다른 이용자의 NFT를 구매하면 한 달 동안 사용할 수 있습니다. (구매 시마다 갱신)
사용법
디시콘에서지갑연결시 바로 사용 가능합니다.