LeetCode 35 Search Insert Position in javascript

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Thank you for this, but you are the first who makes explanation need explanation

davidlee
Автор

I understand binary search but why return left outside while loop

astronaut
Автор

For me this code returns "Time Limit Exceeded"

kwandamadela
Автор

var searchInsert = function(nums, target) {
for(let i = 0 ; i < nums.length ; i++){
if(nums[i]>=target){
return i;
}
}
return nums.length;
};

Clean code is the best solution 😃

behzat