简介
简单题
code
class Solution {
public Integer count = 0;
public void dfs(StringBuffer time, int [] aws, int rlt, int maxNumber){
if(rlt >= maxNumber) return;
int rltc = rlt;
for(int i=0; i<time.length(); i++){
if(aws[i] == 0){
int a = rlt % 10;
rlt = rlt/10;
time.setCharAt(i, (char)('0' + a));
}
}
if( "00".compareTo(time.substring(0,2)) <= 0 && time.substring(0,2).toString().compareTo("23") <= 0
&& "00".compareTo(time.substring(3)) <= 0 && time.substring(3).toString().compareTo("59") <= 0
) {
count++;
}
dfs(time, aws, rltc + 1, maxNumber);
}
public int countTime(String time) {
StringBuffer s = new StringBuffer(time);
int [] aws = new int[]{-1,-1,-1,-1, -1};
int countDefuse = 0;
for (int i = 0; i < s.length(); i++) {
if(s.charAt(i) - '?' == 0){
aws[i] = 0;
countDefuse++;
}
}
dfs(new StringBuffer(time), aws, 0, new Double(Math.pow(10, countDefuse)).intValue());
return count;
}
}
---------------------------我的天空里没有太阳,总是黑夜,但并不暗,因为有东西代替了太阳。虽然没有太阳那么明亮,但对我来说已经足够。凭借着这份光,我便能把黑夜当成白天。我从来就没有太阳,所以不怕失去。
--------《白夜行》