Skip to content

Commit fc10096

Browse files
committed
day16
1 parent c155a28 commit fc10096

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def largestInteger(self, nums: List[int], k: int) -> int:
3+
# k가 전체 길이와 같으면 무조건 최댓값
4+
if k == len(nums):
5+
return max(nums)
6+
7+
# k == 1이면 1번만 나온 숫자 중 최댓값
8+
if k == 1:
9+
arr = [x for x in nums if nums.count(x) == 1]
10+
11+
# 위에 해당되지 않으면 nums[0], nums[-1]만 후보임
12+
else:
13+
arr = [x for x in (nums[0], nums[-1]) if nums.count(x) == 1]
14+
15+
# arr 없으면 -1
16+
return max(arr) if arr else -1

0 commit comments

Comments
 (0)