```
class Solution {
public int searchInsert(int[] nums, int target) {
int n =0;
while(n!=nums.length)
{
if(nums[n] == target)
return n;
if(target > nums[n])
n++;
else
break;
}
return n;
}
}
```