Skip to content

Commit

Permalink
Time: 63 ms, Memory: 42.4 MB - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
karan1205 committed Feb 28, 2022
1 parent 9cf5c6b commit 41839ce
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions find-peak-element/find-peak-element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @param {number[]} nums
* @return {number}
*/
var findPeakElement = function(nums) {
let left = 0;
let right = nums.length -1;

while(left < right) {
const mid = Math.floor((left + right)/2);
if(nums[mid] < nums[mid+1]) {
left = mid+1;
} else {
right = mid;
}
}
return left;
};

0 comments on commit 41839ce

Please sign in to comment.