Skip to content

Commit 9c75025

Browse files
authored
Create 153-find-minimum-in-rotated-sorted-array.js
1 parent 619d4b8 commit 9c75025

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
const findMin = function(nums) {
6+
if(nums.length === 1) return nums[0]
7+
for(let i = 1; i < nums.length; i++) {
8+
if(nums[i] - nums[i - 1] < 0) {
9+
return nums[i]
10+
}
11+
}
12+
return nums[0]
13+
};

0 commit comments

Comments
 (0)