Simple linear search on Java


  • 0
    N

    """
    class Solution {
    public int searchInsert(int[] nums, int target) {
    for(int index = 0; index < nums.length; index++){
    if(nums[index] >= target ){
    return index;
    }
    }
    return nums.length;
    }
    }
    """


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.