일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- mysql
- lambda
- 코테
- programmers
- join
- cte
- lv4
- import re
- sql
- 프로그래머스
- 코딩
- 완전탐색
- Stack
- level4
- time complexity
- coding
- collections
- 코딩테스트
- itertools
- 시간복잡도
- 데이터분석
- Level2
- counter
- 조합
- 연습문제
- Queue
- python
- coding test
- 파이썬
- BFS
- Today
- Total
목록람다 (2)
ror_coding
[Programmers] 콜라 문제 - 132267
lambda a, b, n : max(n-b, 0) // (a-b)*b 람다 사용 .. 꼭 이해 하자!! Question 콜라를 받기 위해 마트에 주어야 하는 병 수 a, 빈 병 a개를 가져다 주면 마트가 주는 콜라 병 수 b, 상빈이가 가지고 있는 빈 병의 개수 n이 매개변수로 주어집니다. 상빈이가 받을 수 있는 콜라의 병 수를 return 하도록 solution 함수를 작성해주세요. Point lambda 사용 : Code 1while 사용 : Code 2 Code 1 : lambda 사용 solution = lambda a, b, n : max(n-b, 0) // (a-b)*b Code 2 : my code def solution(a, b, n): answer = 0 while n/..
Algorithm/Python
2024. 10. 12. 11:08
[Programmers] 문자열 내 마음대로 정렬하기 - 12915
lambda를 이용해 특정 인덱스를 기준으로 문자열 정렬하기 !lambda는 너무 어색해~ㅠㅠ Question 문자열로 구성된 리스트 strings와, 정수 n이 주어졌을 때, 각 문자열의 인덱스 n번째 글자를 기준으로 오름차순 정렬하려 합니다. 예를 들어 strings가 ["sun", "bed", "car"]이고 n이 1이면 각 단어의 인덱스 1의 문자 "u", "e", "a"로 strings를 정렬합니다. Code def solution(strings, n): return sorted(strings, key = lambda x:(x[n],x) ) now meOn my github
Algorithm/Python
2024. 10. 12. 10:59