题目:请实现有重复数字的升序数组的二分查找给定一个 元素有序的(升序)长度为n的整型数组 nums 和一个目标值 target  ,写一个函数搜索 nums 中的第一个出现的target,如果目标值存在返回下标,否则返回 -1数据范围:进阶:时间复杂度,空间复杂度
import java.util.*;public class Solution {    /**     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可     *     * 如果目标值存在返回下标,否则返回 -1     * @param nums int整型一维数组      * @param target int整型      * @return int整型     */    public int search (int[] nums, int target) {        // write code here        if(nums.length==0){          return -1;          }        for(int i=0;i
import java.util.*;public class Solution {    /**     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可     *     * 如果目标值存在返回下标,否则返回 -1     * @param nums int整型一维数组      * @param target int整型      * @return int整型     */    public int search (int[] nums, int target) {        // write code here       if(nums.length==0){           return -1;       }        int i=0;        int j=nums.length-1;        int a=-1;        while(i