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