Search Insert Position

Time limit: 5000ms
Memory limit: 256mb

Description:
Given a sorted integer array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array.

Input:
An integer which is the size of the array.
A sorted integer array where elements are seperated by space.
An integer of the target value.

Output:
You should output only one line which contains an integer of the index.

Sample1
input:
4
1 3 5 6
5

output:
2

Sample2
input:
4
1 3 5 6
0

output:
0
Submit