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.
- Prepare
- Algorithms
- Warmup
- Time Conversion
- Discussions
Time Conversion
Time Conversion
Sort by
recency
|
5067 Discussions
|
Please Login in order to post a comment
Here is my c++ solution, you can watch the vidéo here : https://youtu.be/G7bia__Vxqg
Solution in Kotlin -
py:
def timeConversion(s): if s.endswith('AM'): if s[:2]=='12': g = '00' return g + s[2:-2] return s[:-2] elif s.endswith('PM'): if s[:2]=='12': return (s[:-2]) g = str(int(s[:2])+12) s = g + s[2:-2] return s
if s[:2] == '12' and s[8:] == 'AM': return '00'+ s[2:8] elif s[:2] == '12' and s[8:] == 'PM': return '12' + s[2:8] elif s[8:]== "AM": return s[0:8] else: return str(int(s[:2])+12)+ s[2:8]