Algorithm
[Algorithm][Array] 문제 풀이 #7 - Search in Rotated Sorted Array
Lee David
2022. 7. 18. 23:59
반응형
문제 링크
https://leetcode.com/problems/search-in-rotated-sorted-array/
내 코드
public int search(int[] nums, int target) {
int count = 0;
for(int i = 0; i < nums.length; i++) {
if(nums[i] == target) return count;
count++;
}
return -1;
}
결과
누가봐도 퀵정렬 문제였지만 혹시 몰라 그냥 for문을 돌려 보았더니 왠일...
상위권에 안착하였다.....
모든 코테가 이런식이면 너무 행복할것 같다.
반응형