From f6be9b1de9e99b94f4cd6bf24f179a5e7e8ed17e Mon Sep 17 00:00:00 2001 From: unknown <1326cy@gmail.com> Date: Thu, 13 Aug 2026 22:43:53 +0900 Subject: [PATCH] day15 --- .../1539. Kth Missing Positive Number.py" | 10 ++++++++++ .../611. Valid Triangle Number.py" | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 "leetcode3/\353\202\250\355\232\250\354\240\225/1539. Kth Missing Positive Number.py" create mode 100644 "leetcode3/\353\202\250\355\232\250\354\240\225/611. Valid Triangle Number.py" diff --git "a/leetcode3/\353\202\250\355\232\250\354\240\225/1539. Kth Missing Positive Number.py" "b/leetcode3/\353\202\250\355\232\250\354\240\225/1539. Kth Missing Positive Number.py" new file mode 100644 index 00000000..dba6bd71 --- /dev/null +++ "b/leetcode3/\353\202\250\355\232\250\354\240\225/1539. Kth Missing Positive Number.py" @@ -0,0 +1,10 @@ +class Solution: + def findKthPositive(self, arr: List[int], k: int) -> int: + miss_num = 0 + cnt = 0 + while True: + miss_num += 1 + if miss_num not in arr: + cnt += 1 + if k == cnt: + return miss_num \ No newline at end of file diff --git "a/leetcode3/\353\202\250\355\232\250\354\240\225/611. Valid Triangle Number.py" "b/leetcode3/\353\202\250\355\232\250\354\240\225/611. Valid Triangle Number.py" new file mode 100644 index 00000000..78f27e3b --- /dev/null +++ "b/leetcode3/\353\202\250\355\232\250\354\240\225/611. Valid Triangle Number.py" @@ -0,0 +1,20 @@ +# 풀이 실패 +class Solution: + def triangleNumber(self, nums: List[int]) -> int: + nums.sort() + cnt = 0 + N = len(nums) + + for k in range(N-1, 1, -1): + left = 0 + right = k - 1 + + # 투 포인터 + while left < right: + if nums[left] + nums[right] > nums[k]: + cnt += right - left + right -= 1 + else: + left += 1 + + return cnt