Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- BOJ
- sw expert academy
- Python
- 재귀
- 14863
- 해시해킹
- 15353
- 브루트포스
- 1로만들기2
- C++
- dart
- 서울에서경산까지
- BOJ14889
- 회전하는큐
- Flutter
- 백준
- Crossfit
- 그리디
- 삼성
- 26008
- 15662
- spring boot
- 재귀함수
- DP
- 4811
- 1781
- 스택
- 크로스핏
- D1
- 동적프로그래밍
Archives
- Today
- Total
곧죽어도 콛잉
[프로그래머스 / Python] 나누어 떨어지는 숫자 배열 본문
https://school.programmers.co.kr/learn/courses/30/lessons/12910
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
쉽다~
리스트 컴프리헤션을 쓰면 더 짧아진다
def solution(arr, divisor):
answer = []
for i in arr:
if i%divisor==0 : answer.append(i)
answer.sort()
if not answer : answer.append(-1)
return answer
# ======== 리스트 컴프리헤션 =======
def solution2(arr, divisor):
answer = [i for i in arr if i%divisor==0]
answer.sort()
if not answer : answer.append(-1)
return answer
'Coding Test > Python' 카테고리의 다른 글
[프로그래머스 / Python] 의상 (0) | 2024.02.26 |
---|---|
[BOJ 26008 / Python] 해시해킹 (0) | 2024.02.26 |
[BOJ 10818 / Python] 최소, 최대 (0) | 2024.02.21 |
[프로그래머스 / Python] 기능개발 (0) | 2024.02.20 |
[BOJ 1021 / Python] 회전하는 큐 (0) | 2024.02.20 |
Comments