PS/LeetCode 3254. Find the Power of K-Size Subarrays I - Problem : https://leetcode.com/problems/find-the-power-of-k-size-subarrays-iDifficulty : MediumStatus : SolvedTime : ??:??:?? 풀이어떻게 문제를 분류해 볼 수 있을까.. 싶은 문제.연속 숫자로 sort된 길이를 임시로 저장해가며, 그 길이가 k 이상이면 그 인덱스의 숫자를 (maximum 값이 현재 index임이 충족된다), 그렇지 않다면 -1을 담아 반환하기만 하면 된다.기본적인 sort 개념을 어떻게 응용해 볼 수 있을까를 물어보는 문제라고 생각한다.풀이 코드class Solution: def resultsArray(self, nums: List[int], k: int) -> List[int]: sortLen = [1]*len(nums) for i in range(len(nums)-1) : if nums[i]+1 == nums[i+1] : sortLen[i+1] = sortLen[i]+1 return [ nums[i] if sortLen[i] >= k else -1 for i in range(k-1, len(nums)) ] 공유하기 URL 복사카카오톡 공유페이스북 공유엑스 공유 게시글 관리 구독하기마젠티노's Contents 풀이 풀이코드 당신이 좋아할만한 콘텐츠 2461. Maximum Sum of Distinct Subarrays With Length K 2024.11.19 1652. Defuse the Bomb 2024.11.18 2064. Minimized Maximum of Products Distributed to Any Store 2024.11.14 2563. Count the Number of Fair Pairs 2024.11.13 댓글 0 + 이전 댓글 더보기