Skip to content

Commit 4106ea3

Browse files
Merge pull request #1837 from CodingTestStudy2/최원준
[최원준] Day16
2 parents c155a28 + 9c20ee5 commit 4106ea3

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from collections import Counter
2+
3+
class Solution:
4+
def largestInteger(self, nums: List[int], k: int) -> int:
5+
n = len(nums)
6+
counter = Counter(nums)
7+
8+
if k == n:
9+
return max(nums)
10+
11+
if k == 1:
12+
ans = -1
13+
14+
for num in nums:
15+
if counter[num] == 1:
16+
ans = max(ans, num)
17+
18+
return ans
19+
20+
# 1 < k < n
21+
ans = -1
22+
23+
if counter[nums[0]] == 1:
24+
ans = max(ans, nums[0])
25+
26+
if counter[nums[-1]] == 1:
27+
ans = max(ans, nums[-1])
28+
29+
return ans

0 commit comments

Comments
 (0)