We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 48de4a9 commit 699afbbCopy full SHA for 699afbb
LEVEL2/Day1/pocketmon.py
@@ -1,6 +1,25 @@
1
+# 첫 풀이
2
def solution(nums):
3
- mySet = set(nums)
4
- if len(mySet) > int(len(nums)/2) :
+ pocketmon = set(nums)
5
+ if len(pocketmon) > int(len(nums)/2) :
6
return int(len(nums)/2)
- return len(mySet)
7
+ return len(pocketmon)
8
+
9
+## 2번재 풀이
10
11
+def solution(nums):
12
+ pocketmon = [] # 새로운 종류의 폰켓몬을 선택하면 이 리스트에 넣음.
13
+ for i in nums:
14
+ try:
15
+ if pocketmon.index(i) >= 0: # 겹치면 answer_list에 추가하지 않기
16
+ continue
17
+ except:
18
+ pocketmon.append(i)
19
20
+ if len(pocketmon) >= len(nums) / 2:
21
+ return len(nums) / 2
22
+ else:
23
24
25
+ return min(len(nums) / 2, len(pocketmon)) # len()을 활용해서 더 간략하게 수정
0 commit comments