class Solution {

public int searchInsert(int[] nums, int target) {

int len=nums.length;

int pos =0;

for(int i=0;i<len;i++){

if(target<=nums[i]){

pos=i;

break;

}

else if(target>nums[i]&&i==len-1||target>nums[i]&&target<=nums[i+1]){

pos=i+1;

break;

}

}

return pos;

}

}