#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
int low = 0;
int hight = nums.size() - 1;
int mid = 0;
while (low <= hight){
mid = (low + hight) / 2;
if (nums[mid] < target){
low = mid + 1;
}
else if (nums[mid] > target){
hight = mid - 1;
}
else{
return mid;
}
}
return nums[mid] > target ? mid : mid + 1;
}
};
int main(){
vector<int> a = { 1, 3, 5, 6 };
Solution s;
int b = s.searchInsert(a, 2);
cout << b;
return 0;
}