일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 스탭퍼
- 10분
- 영어공부
- 리얼 클래스
- 링피트
- 파비최
- 월간
- 미드시청
- leetcode
- 잡생각
- 사이드
- 읽기
- English
- Daily Challenge
- 괜찮음
- 만화도
- FIT XR
- 운동
- 매일
- 30분
- 프로젝트
- Problem Solving
- 개발자
- 3줄정리
- 화상영어
- realclass
- 영어원서읽기
- Writing
- 쓰릴오브파이트
- 뭐든
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/sort-array-by-parity
Sort Array By Parity - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
문제가 너무 쉬워서 문제 풀고 나서 해설 봄.
좀 더 간단(혹은 간편)한 해결책이 있으면 했는데 잘 안나오네..
class Solution:
def sortArrayByParity(self, nums: List[int]) -> List[int]:
even, odd = list(), list()
for num in nums:
if num % 2 == 0:
even.append(num)
continue
odd.append(num)
return even + odd
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2022.05.04 |
---|---|
Today's Challenge (0) | 2022.05.03 |
Today's Challenge (0) | 2022.05.01 |
Today's Challenge (0) | 2022.04.30 |
Today's Challenge (0) | 2022.04.29 |
Comments