public static int findPeakElement(int[] num) {
        for (int l=0, r=num.length-1;;) {
            int m=l+(r-l)/2;
            if (l==r)
                return l;
            else if (num[m]<num[m+1])
                l=m+1;
            else if (num[m]>num[m+1])
                r=m;
        }
    }