From ceb1a3d3f1b5ee01710f112ee7b34847f2139b04 Mon Sep 17 00:00:00 2001 From: ji-hyup Date: Fri, 14 Aug 2026 17:29:54 +0900 Subject: [PATCH] 3471 --- ...ind the Largest Almost Missing Integer.py" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "leetcode3/\353\263\200\354\247\200\355\230\221/v2/3471. Find the Largest Almost Missing Integer.py" diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v2/3471. Find the Largest Almost Missing Integer.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v2/3471. Find the Largest Almost Missing Integer.py" new file mode 100644 index 00000000..adc88657 --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v2/3471. Find the Largest Almost Missing Integer.py" @@ -0,0 +1,28 @@ +''' +1. 아이디어 : +k만큼의 부분배열을 만들고, 부분배열에 포함되는 갯수 센다. + +2. 시간복잡도 : +O(n*k) + +3. 자료구조/알고리즘 : +''' +from collections import defaultdict +class Solution: + def largestInteger(self, nums: List[int], k: int) -> int: + n = len(nums) + dic = defaultdict(int) + for i in range(n-k+1): + sub = nums[i:i+k] + st = set() + for j in sub: + st.add(j) + for j in st: + dic[j] += 1 + + print(dic) + + try: + return max([key for key,value in dic.items() if value == 1]) + except: + return -1 \ No newline at end of file