直接暴力枚举
class Solution { public: bool check(string time,string res){ for(int i = 0;i < 5;i++){ if(time[i] == res[i] || time[i] == '?') continue; return false; } return true; } string maximumTime(string time) { for(int i = 23;i >= 0;i--){ for(int j = 59;j >= 0;j--){ char res[10]; sprintf(res,"%02d:%02d",i,j); if(check(time,res)) return res; } } return ""; } };