Skip to content

Commit 7e04294

Browse files
Merge pull request #1825 from CodingTestStudy2/최민지
[최민지] Day15
2 parents 7222a8f + 0aa9480 commit 7e04294

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎leetcode3/최민지/1539.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def findKthPositive(self, arr: List[int], k: int) -> int:
3+
count = 0
4+
for i in range(1,1001):
5+
if i not in arr:
6+
count += 1
7+
if count == k:
8+
return i
9+

‎leetcode3/최민지/611.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Solution:
2+
def triangleNumber(self, nums: List[int]) -> int:
3+
nums.sort()
4+
# 삼각형 조건: a + b > c
5+
6+
count = 0
7+
for i in range(len(nums)-1, -1, -1):
8+
c = nums[i]
9+
10+
left = 0
11+
right = i-1
12+
13+
while left < right:
14+
if nums[left] + nums[right] > c:
15+
count += right - left
16+
right -= 1
17+
else:
18+
left += 1
19+
20+
#for j in range(i-1, -1, -1):
21+
# b = nums[j]
22+
# for k in range(j-1,-1, -1):
23+
# a = nums[k]
24+
25+
# if a + b > c:
26+
# count += 1
27+
28+
return count
29+

0 commit comments

Comments
 (0)