Skip to content

Commit 3629c89

Browse files
committed
feat: Add solution for LeetCode problem 153
1 parent 24f4a4d commit 3629c89

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// 153. Find Minimum in Rotated Sorted Array
3+
// https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/description/
4+
// Dale-Study
5+
//
6+
// Created by WhiteHyun on 2024/06/09.
7+
//
8+
9+
class Solution {
10+
func findMin(_ nums: [Int]) -> Int {
11+
var left = 0
12+
var right = nums.count - 1
13+
while left < right {
14+
let mid = (left + right) >> 1
15+
16+
if nums[mid] > nums[right] {
17+
left = mid + 1
18+
} else {
19+
right = mid
20+
}
21+
}
22+
23+
return nums[left]
24+
}
25+
}

0 commit comments

Comments
 (0)