We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed599cd commit 8dbd72dCopy full SHA for 8dbd72d
find-minimum-in-rotated-sorted-array/jinhyungrhee.java
@@ -0,0 +1,17 @@
1
+class Solution {
2
+ public int findMin(int[] nums) {
3
+ int left = 0, right = nums.length - 1;
4
+ // 오름차순인 경우
5
+ if (nums[left] < nums[right]) return nums[left];
6
+ // 오름차순이 아닌 경우 이진탐색
7
+ while (left < right) {
8
+ int mid = (left + right) / 2;
9
+ if (nums[mid] < nums[right]) {
10
+ right = mid;
11
+ } else {
12
+ left = mid + 1;
13
+ }
14
15
+ return nums[left];
16
17
+}
0 commit comments