* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
 *
 * 
 * @param nums int整型一维数组 
 * @param target int整型 
 * @return int整型
 */
function search( nums ,  target ) {
    // write code here
    let len = nums.length
    if(!len)return -1
    let [left , right] = [0 , len -1]
    while(left <= right){
        let mid = left + Math.floor((right - left) /2)
        let num = nums[mid]
        if(num === target) return mid
        else if(num > target) right = mid - 1
        else left = mid +1
        
    }
    return -1
}
module.exports = {
    search : search
};