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.
Here is my c++ solution, you can watch the explanation here : https://youtu.be/G7bia__Vxqg
I'll be happy to hear back from you
#include<bits/stdc++.h>usingnamespacestd;// morning h == 12 = > 0// evening h != 12 => h +=12intmain(){strings;cin>>s;inth;sscanf(s.c_str(),"%d",&h);if(s[8]=='A'&&h==12)h=0;if(s[8]=='P'&&h!=12)h+=12;cout<<setw(2)<<setfill('0')<<h;cout<<s.substr(2,6);return0;}
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 →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/G7bia__Vxqg I'll be happy to hear back from you