35. Search Insert Position
easy
最后返回的是nums.length
1 class Solution { 2 public int searchInsert(int[] nums, int target) { 3 if(nums.length == 0) return 0; 4 for(int i = 0; i < nums.length; i++) { 5 if(nums[i] == target) { 6 return i; 7 }else if(nums[i] > target) { 8 return i; 9 } 10 } 11 return nums.length; 12 13 } 14 }