标签:style blog class code java tar
很简单的题目,一次过,注意为数组空的时候,应返回0而非null
1 public class Solution { 2 public int searchInsert(int[] A, int target) { 3 int i; 4 if (A.length == 0) return 0; 5 for (i=0; i<A.length; i++){ 6 if (target <= A[i]){ 7 return i; 8 } 9 } 10 return A.length; 11 } 12 }
Leetcode: Search Insert Position,布布扣,bubuko.com
Leetcode: Search Insert Position
标签:style blog class code java tar
原文地址:http://www.cnblogs.com/EdwardLiu/p/3719940.html