-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BST] bj10815 - 숫자카드 #6
base: main
Are you sure you want to change the base?
Conversation
상근이는 왜 카드놀이를 했는가...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
깔끔한다 고생했어
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿입니당~
while left <= right : | ||
medium = (left + right) // 2 | ||
|
||
# 각각의 요소들을 확인하는 문제 | ||
if array[medium] == data: | ||
return medium | ||
# 중간 값보다 작다면, 중간보다 한칸 왼쪽 탐색 | ||
elif array[medium] > data: | ||
right = medium - 1 | ||
# 중간값보다 크다면 오른쪽 한 칸 앞 탐색 | ||
else : | ||
left = medium + 1 | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반복문으로 했구나 좋다 !!
문제에서 출력문 값은 0 아니면 1이니까 return을 각각 0이랑 1로 변경해도 깔끔할 것 같네~~
상근이는 왜 카드놀이를 했는가...
📒 문제번호 : 10815번 숫자카드
☑️ PR Point
⏱️시간복잡도