Skip to content

Commit 2123c0c

Browse files
committed
find minimum in rotated sorted array solved
1 parent 5e2292a commit 2123c0c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
// 시간복잡도: O(n)
3+
// 공간복잡도: O(1)
4+
public int findMin(int[] nums) {
5+
for(int i = 1; i < nums.length; i++) {
6+
if(nums[i - 1] > nums[i]) {
7+
return nums[i];
8+
}
9+
}
10+
11+
return nums[0];
12+
}
13+
}

0 commit comments

Comments
 (0)