Binary Search Examples #230
esthicodes
started this conversation in
General
Replies: 3 comments
-
#brute force time complex O(N)#space complex O(McN) i O(1) -> constantdef index_equals_value_search1(arr): def index_equals_value_search(arr):
https://leetcode.com/problems/binary-search/Binary search - youtubedef search(nums, target):
https://www.youtube.com/watch?v=P3YID7liBug |
Beta Was this translation helpful? Give feedback.
0 replies
-
何の話しか私ぜんぜんわからない でもきっと 意味のあるものだと信じてる
2023년 4월 27일 (목) 오전 8:30, hona ***@***.***>님이 작성:
… class Solution(object):
def search(self, nums, target):
# self is a class of method "Solution".
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
left = 0
right = len(nums) - 1
while left <= right:
mid = (left + right) // 2
if nums[mid] == target:
return mid
elif nums[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
—
Reply to this email directly, view it on GitHub
<#230>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5JJWBNSZ5KSIEJ442QDCY3XDGV2HANCNFSM6AAAAAAXNC43VE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Hoeun, where are you?
Are you OK? Did I do wrong?
Are you feel terrible?
Please call me I will go
We were supposed to meet this week. Let's eat delicious things and talk
what happened.
I am sorry that I didn't think about you.. please back me message!!!!!
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Beta Was this translation helpful? Give feedback.
All reactions