You are viewing a single comment's thread. Return to all comments →
Another C# Solution
public static string timeConversion(string s) { var hr = s.Split(":"); var hora = Convert.ToInt32(hr[0]); if(hr[2].Contains("PM")) { if(hora != 12) hora += 12; hr[0]= hora.ToString("D2"); hr[2] = hr[2].Replace("PM", ""); } else { if(hora == 12) { hora = 0; } hr[0] = hora.ToString("D2"); hr[2] = hr[2].Replace("AM", ""); } return $"{hr[0]}:{hr[1]}:{hr[2]}"; }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Time Conversion
You are viewing a single comment's thread. Return to all comments →
Another C# Solution