일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- 운영체제
- 파이썬
- Python
- 밴픽
- attribute
- concurrency
- DWG
- Python Implementation
- Class
- Regular Expression
- shiba
- 315. Count of Smaller Numbers After Self
- 715. Range Module
- kaggle
- LeetCode
- Python Code
- 컴퓨터의 구조
- 43. Multiply Strings
- data science
- Convert Sorted List to Binary Search Tree
- Generator
- 109. Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- Decorator
- iterator
- 프로그래머스
- Protocol
- 시바견
- t1
- Today
- Total
목록Convert Sorted List to Binary Search Tree (2)
Scribbling
O(N) Time complexity, O(1) Memory Solution using Recursion # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def sortedListToBST(self, he..
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def sortedListToBST(self, head: Optional[ListNode]) -> Optional[TreeNode]: if not head:..