일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 30분
- 스탭퍼
- 매일
- Daily Challenge
- 파비최
- Writing
- realclass
- 뭐든
- 3줄정리
- 괜찮음
- FIT XR
- English
- 사이드
- 개발자
- 화상영어
- 잡생각
- 영어공부
- 읽기
- 월간
- 프로젝트
- 운동
- 영어원서읽기
- 리얼 클래스
- 링피트
- 미드시청
- Problem Solving
- leetcode
- 만화도
- 쓰릴오브파이트
- 10분
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/partition-list/
Partition List - 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 partition(self, head: Optional[ListNode], x: int) -> Optional[ListNode]:
before = before_head = ListNode(0)
after = after_head = ListNode(0)
while head:
if head.val < x:
before.next = head
before = before.next
else:
after.next = head
after = after.next
head = head.next
after.next = None
before.next = after_head.next
return before_head.next
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2022.07.24 |
---|---|
Today's Challenge (0) | 2022.07.23 |
Today's Challenge (0) | 2022.07.21 |
Today's Challenge (0) | 2022.07.20 |
Today's Challenge (0) | 2022.07.19 |
Comments