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.
- Time Conversion
- Discussions
Time Conversion
Time Conversion
Sort by
recency
|
879 Discussions
|
Please Login in order to post a comment
Most of the solutions im seeing are overdoing it or using packages (which imo is lowkey cheating LOL) but here's how i kept it beginner friendly 🫡 This also has a time complexity of O(1) iirc
with comments because those are important
include
using namespace std;
/* * Complete the 'timeConversion' function below. * * The function is expected to return a STRING. * The function accepts STRING s as parameter. */
string timeConversion(string s) { string period = s.substr(8, 2); // Extract AM or PM string hour_str = s.substr(0, 2); int hour = stoi(hour_str); string remaining = s.substr(2, 6); // Remaining part after hour (":MM:SS")
}
int main() { ofstream fout(getenv("OUTPUT_PATH"));
}
I used Java and tried to keep it simple and easy to read
GO
def timeConversion(s): # Write your code here
if name == 'main':