Skip to content

Commit

Permalink
Udpate _posts
Browse files Browse the repository at this point in the history
-Rename the post
-add describtion
  • Loading branch information
0package committed Sep 30, 2024
1 parent 5333d2e commit a9f1dc1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 112 deletions.
28 changes: 28 additions & 0 deletions _posts/2024-09-30-Pocketmon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
layout: single
title: "Programmers_폰켓몬(Hash, Dictionary)"
---

## 딕셔너리(Key-Value)를 사용한 파이썬 풀이

```python
def solution(nums):
answer = 0
l = len(nums)
pocketmons = {} #dic {포켓몬 번호 : 개수}
for i in nums:
if i in pocketmons:
pocketmons[i] += 1 #키가 있다면 개수 + 1
else:
pocketmons[i] = 1 #키가 없다면 1로 초기화

# 포켓몬 키 값 개수(중복 없음)
answer = len(pocketmons.keys())

#구한 값이 l/2와 같거나 크다면 l/2가 답
if answer >= l/2:
answer = l/2

return answer

```
112 changes: 0 additions & 112 deletions _posts/Programmers.md

This file was deleted.

0 comments on commit a9f1dc1

Please sign in to comment.