Array=0822

public void moveMulti(int []num,int mi){
    if (num==null||num.length==0){return;
    }
    mi=mi%num.length;
    reverse(num, 0, num.length - 1);
    reverse(num, 0, mi-1);
    reverse(num,mi,num.length-1);
}

private void reverseBetween(int []num,int i,int j){
    while(i<=j){int temp = num[i];num[i] = num[j];nums[j]=nums[i];i++;j--;}
}

//isMatch(s, p, s.length()-1, p.length()-1);
public Boolean isMatch(String s, String p, int i, int j) {
    if (i == -1 || j == -1) {if (i==j) {return true;}return false;}
    final char oneFlag='?';final char multiFlag='*';
    if (oneFlag==p.charAt(j) || p.charAt(j) == s.charAt(i)) {
        return isMatch(s, p, i - 1, j - 1);
    }
    if (multiFlag==(p.charAt(j))) {
        return isMultiSmall(s,p,i,j);
    }
    return false;
}

private Boolean isMultiSmall(String s, String p, int i, int j){
    int tj = j;
    while (tj >= 0) {
        tj=tj-1;
        if (isMatch(s, p, i - 1, tj) == true) {return true;}
    }
    return false;
}

//generatePair(3,3,"",ansList)
public void generatePair(int ir, int jr, String oneAns,List ansList) {
    if(ir==0 &&jr==0) {ansList.add(oneAns);}
    if(ir>0) {generatePair(ir - 1, jr, oneAns + '(', ansList);}
    if(jr>0 && ir < jr) {
        generatePair(ir, jr - 1, oneAns + ')',ansList);}
}

public int findEquals(int [] nums, int target) {
    int i = 0, j = nums.length;
    while (i < j) {
        int m = i + (j-i) / 2;int middle=nums[m];
        if (middle== target) {return m;}
        if (middle>target){j=m-1;}
        else{i=m+1;}
    }
    return -1;
}

public int findFirstBigger(int[] nums, int target) {
    int i = 0, j = nums.length;
    while (i < j) {
        int m= i + (j - i) / 2;int middle=nums[m];
        if (middle>target){j=m-1;ans=m;}
        else {i=m+1;}
    }
    return i;
}

你可能感兴趣的:(Array=0822)