We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int hh = stoi(s.substr(0,2));
string f = s.substr(8,2);
string ret = s.substr(0,8);
if (f == "AM") {
if (hh == 12) ret = ret.replace(0,2,"00");
} else if (hh!=12) {
hh+=12;
ret = ret.replace(0,2,to_string(hh));
} return ret;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →