STUDY/LeetCode
LeetCode - 704. Binary Search
뚱냐리
2022. 7. 7. 00:19
반응형
역쉬....
사람은 공부를 계속 해야합니다 ...
허허허
이런 문제 하나 맞추거 겁나 좋아하는 나라니
여태 뭘한건가요 ~ ㅠㅠ
https://leetcode.com/problems/binary-search/
Binary Search - 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
요 문제 !
E-Z ~
int search(int* nums, int numsSize, int target){
int mid = 0;
mid = numsSize>>1;
if(target < nums[mid]) {
for(int i = 0; i < mid; i++) {
if(nums[i] == target) return i;
}
} else {
for(int i = mid; i < numsSize; i++) {
if(nums[i] == target) return i;
}
}
return -1;
}
근데 글로발 지니어스들은 진짜 ...
다른 사람들이 푼거 보면 얼굴 씨게 얻어맞는 기분..
내가 겁나 더럽게 푼거를 3줄로 ^^....
하..... 비루해지는 나으 소스들...
728x90
반응형