Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Git
- ubuntu
- 편스토랑 우승상품
- gs25
- 맥북
- 자연어처리
- Real or Not? NLP with Disaster Tweets
- SW Expert Academy
- 편스토랑
- PYTHON
- 캐치카페
- AI 경진대회
- 더현대서울 맛집
- 프로그래머스
- Docker
- Kaggle
- elasticsearch
- programmers
- 코로나19
- 백준
- 우분투
- leetcode
- github
- 금융문자분석경진대회
- Baekjoon
- 캐글
- 파이썬
- 데이콘
- hackerrank
- dacon
- Today
- 300
- Total
- 2,245,986
솜씨좋은장씨
[Programmers] 최빈값 구하기 (Python) 본문
728x90
반응형
코딩 1일 1문제! 오늘의 문제는 프로그래머스의 최빈값 구하기 입니다.
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
👨🏻💻 코드 ( Solution )
def solution(array):
answer = -1
freq_check = {}
for num in array:
if num not in freq_check:
freq_check[num] = 0
freq_check[num] += 1
freq_items = sorted(freq_check.items(), key=lambda x: (-x[1]))
if (len(freq_items) > 1 and freq_items[0][1] != freq_items[1][1]) or len(freq_items) == 1:
answer = freq_items[0][0]
return answer
GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[BaekJoon] 27327번 : 時間 (Hour) (Python) (0) | 2023.01.31 |
---|---|
[BaekJoon] 27294번 : 몇개고? (Python) (0) | 2023.01.30 |
[Programmers] 2023 KAKAO BLIND RECRUITMENT - 개인정보 수집 유효기간 (Python) (0) | 2023.01.26 |
[BaekJoon] 23809번 : 골뱅이 찍기 - 돌아간 ㅈ (Python) (1) | 2023.01.25 |
[BaekJoon] 26561번 : Population (Python) (0) | 2023.01.24 |
2 Comments