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.
functimeConversion(sstring)string{milLayout:="15:04:05"amPmLayout:="03:04:05PM"//handle err if u needt,_:=time.Parse(amPmLayout,s)returnt.Format(milLayout)}
algo
functimeConversion(sstring)string{out:=[]rune(s)varisPmintifs[len(out)-2:]=="PM"{isPm=1}else{isPm=0}//handle err if u needhours,_:=strconv.Atoi(s[:2])ifisPm==1&&hours!=12{hours+=12}elseifisPm==0&&hours==12{hours=0}out[0]=rune(hours/10+'0')out[1]=rune(hours%10+'0')out=out[:len(out)-2]returnstring(out)}
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 →
GO