public int find(int[] A, int sta, int end,int target,boolean flag){
        if(sta > end)
            return -1;
        else{
            int mid = (sta + end) / 2 ;
            if(A[mid] == target){
                if(flag){
                    //find minIndex
                    int index = mid-1;
                    if(index  < sta)
                        return sta;
                    if(A[mid-1] == target)   //确保find 函数肯定能找到一个。
                        return find(A,sta,mid-1,target,flag);
                    else
                        return mid;
                }
                else{
                    int index = mid+1;
                    if(index  > end)
                        return end;
                    if(A[mid+1] == target) //确保find 函数肯定能找到一个。
                        return find(A,mid+1,end,target,flag);
                    else
                        return mid;
                }
            }
            else if(A[mid] > target){
                // x > target  find target in the left
                return find(A,sta,mid-1,target,flag);
            }else
                // x < target  find target in the right
                return find(A,mid+1,end,target,flag);
        }
    }