Search Insert Position--Java version


  • 0
    H

    Java version

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

Log in to reply
 

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