Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

loveitall
Copy link
Collaborator

상근이는 왜 카드놀이를 했는가...

📒 문제번호 : 10815번 숫자카드

☑️ PR Point

  • 여기서는 절반씩 탐색하는 방법에 대한 방법을 잘 모르겠어서 찾아보고 이해하는 방식으로 문제를 풀었습니닷!!

image

⏱️시간복잡도

상근이는 왜 카드놀이를 했는가...
@loveitall loveitall requested a review from a team as a code owner February 19, 2023 08:07
@loveitall loveitall requested review from skylartosf, wkdyujin and IslandofDream and removed request for a team February 19, 2023 08:07
@loveitall loveitall added the BST label Feb 19, 2023
@loveitall loveitall changed the title [bj10815] - 숫자카드 [BST] bj10815 - 숫자카드 Feb 19, 2023
@loveitall loveitall self-assigned this Feb 19, 2023
Copy link
Member

@IslandofDream IslandofDream left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔한다 고생했어

Copy link

@wkdyujin wkdyujin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿입니당~

Comment on lines +13 to +25
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

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로 변경해도 깔끔할 것 같네~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants