본문으로 건너뛰기

"tistory" 태그로 연결된 338개 게시물개의 게시물이 있습니다.

모든 태그 보기

105. Construct Binary Tree from Preorder and Inorder Traversal

· 약 2분
Seokjae Lee
Software engineer

원문: https://doljae.tistory.com/166

[Construct Binary Tree from Preorder and Inorder Traversal - 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](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)

lower_bound, upper_bound

· 약 1분
Seokjae Lee
Software engineer

원문: https://doljae.tistory.com/165

def lower_bound(input_list, target_value):
if not input_list:
return 0
lo, hi = 0, len(input_list)
while lo < hi:
mid = (lo + hi) // 2
if input_list[mid] < target_value:
lo = mid + 1
else:
hi = mid

return lo

def upper_bound(input_list, target_value):
if not input_list:
return 0
lo, hi = 0, len(input_list)
while lo < hi:
mid = (lo + hi) // 2
if target_value < input_list[mid]:
hi = mid
else:
lo = mid + 1