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 72e9a27 commit 2bc1c6eCopy full SHA for 2bc1c6e
1 file changed
find-minimum-in-rotated-sorted-array/tigermint.kt
@@ -0,0 +1,17 @@
1
+class Solution {
2
+ fun findMin(nums: IntArray): Int {
3
+ var left = 0
4
+ var right = nums.size - 1
5
+
6
+ while (left < right) {
7
+ val mid = (left + right) / 2
8
9
+ when {
10
+ nums[mid] > nums[right] -> left = mid + 1 // 오른쪽 존재
11
+ nums[mid] <= nums[right] -> right = mid // 왼쪽 존재 or 나 자신
12
+ }
13
14
15
+ return nums[left]
16
17
+}
0 commit comments