Posted on

Description

Submission

class Solution {
public:
    string maximumTime(string time) {
        string ret;
        if(time[0] == '?') {
            if(time[1] == '?') {
                ret += "23";
            } else {
                if(time[1] > '3') {
                    ret += "1";
                } else {
                    ret += "2";
                }
                ret.push_back(time[1]);
            }
        } else {
            ret.push_back(time[0]);
            if(time[1] == '?') {
                if(time[0] < '2') {
                    ret += "9";
                } else {
                    ret += "3";
                }
            } else {
                ret.push_back(time[1]);
            }
        }
        ret += ":";

        if(time[3] == '?') {
            ret += "5";
        } else {
            ret.push_back(time[3]);
        }

        if(time[4] == '?') {
            ret += "9";
        } else {
            ret.push_back(time[4]);
        }

        return ret;
    }
};

// "2?:?0": 2 parts.  2? and ?0

Leave a Reply

Your email address will not be published. Required fields are marked *