JSFiddle - React, Tailwind, and code Playground
by Prathameshsb
CSS
* {
background-color: #2c2c2c;
}
JavaScript
function test(num) {
let left = 0;
let right = num.length - 1;
while(left < right) {
const mid = Math.floor((left + right)/2)
if(num[mid] > num[mid + 1]) {
right = mid;
}else {
left = mid + 1;
}
}
return left
}
console.log(test([1,2,1,3,5,6,4]))