일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 43. Multiply Strings
- t1
- shiba
- 컴퓨터의 구조
- 시바견
- concurrency
- Decorator
- LeetCode
- 밴픽
- Generator
- 운영체제
- DWG
- Protocol
- Python Code
- Regular Expression
- Convert Sorted List to Binary Search Tree
- 109. Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- Python Implementation
- attribute
- 315. Count of Smaller Numbers After Self
- 프로그래머스
- kaggle
- 715. Range Module
- Python
- 30. Substring with Concatenation of All Words
- data science
- Class
- 파이썬
- iterator
Archives
- Today
- Total
Scribbling
LeetCode: 206. Reverse Linked List 본문
Iterative가 빠르다.
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
cur, prv = head, None
while cur:
nxt = cur.next
cur.next = prv
prv = cur
cur = nxt
return prv
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 239. Sliding Window Maximum (0) | 2021.12.23 |
---|---|
LeetCode: 218. The Skyline Problem (0) | 2021.12.22 |
LeetCode: 202. Happy Number (0) | 2021.12.21 |
LeetCode: 191. Number of 1 Bits (0) | 2021.12.21 |
LeetCode: 171. Excel Sheet Column Number (0) | 2021.12.20 |