일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 데이터분석
- 코딩테스트
- 파이썬
- lambda
- 시간복잡도
- join
- BFS
- Stack
- mysql
- 완전탐색
- 코딩
- coding
- 프로그래머스
- collections
- python
- import re
- Level2
- 코테
- lv4
- time complexity
- sql
- counter
- level4
- coding test
- CodingTest
- programmers
- itertools
- Queue
- 연습문제
- 조합
- Today
- Total
목록귤 고르기 (1)
ror_coding
[Programmers] 귤 고르기 - 138476
Counter 에서 값들을 기준으로 정렬하는 코드로 .most_common() 이 있다! Question 한 상자에 담으려는 귤의 개수 k와 귤의 크기를 담은 배열 tangerine이 매개변수로 주어집니다. 귤 k개를 고를 때 크기가 서로 다른 종류의 수의 최솟값을 return 하도록 solution 함수를 작성해주세요. Code from collections import Counterdef solution(k, tangerine): cnt = 0 a = Counter(tangerine) for item, count in a.most_common(): k -= count cnt += 1 if k now meOn my github
Algorithm/Python
2024. 10. 24. 12:29