LeetCode Solutions/Algorithm I/Day 1 Binary Search/Search Insert Position.java
class Solution {
    public int searchInsert(int[] nums, int target) {
        int low = 0, high = nums.length-1, mid = 0;
        while (low <= high){
            mid = low + (high-low)/2;
            if (nums[mid] == target){
                return mid;
            }
            else if (nums[mid] < target){
                low = mid + 1;
            }
            else{
                high = mid - 1;
            }
        }
        return low;
    }
}