public class Solution {
/**
* @param time: a string of Time
* @return: The MaximumMoment
*/
public String MaximumMoment(String time) {
char[] charAry = time.toCharArray();
if (charAry[0] == '?') {
if (charAry[1] >= '4' && charAry[1] <= '9') {
charAry[0] = '1';
} else {
charAry[0] = '2'; // charAry[1] == '?' also give charAry[0] = '2'
}
}
if (charAry[1] == '?') {
if (charAry[0] != '2') {
charAry[1] = '9';
} else {
charAry[1] = '3';
}
}
charAry[3] = (charAry[3] == '?') ? '5' : charAry[3];
charAry[4] = (charAry[4] == '?') ? '9' : charAry[4];
return String.valueOf(charAry);
}
}j