035.Search Insert Positio Posted on 2017-09-13 | In LeetCode Solution 1: accepted 7msNormal iteration.Time: O(n)Space: O(1) 12345678910public int searchInsert(int[] nums, int target) { int prev = Integer.MIN_VALUE; for (int i = 0; i < nums.length; i++) { if (nums[i] == target) return i; else if (target > prev && target < nums[i]) return i; } return nums.length;} Solution 2: accepted 7msBinary search.Time: O(logn)Space: O(1)