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.
letAMPM=s.slice(-2);lettimeArr=s.slice(0,-2).split(":");if(AMPM==="AM"&&timeArr[0]==="12"){// catching edge-case of 12AMtimeArr[0]="00";}elseif(AMPM==="PM"){// everything with PM can just be mod'd and added with 12 - the max will be 23timeArr[0]=(timeArr[0]%12)+12}returntimeArr.join(":");
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's a simple solution in javascript