Hackerrank's Problem Solving solutions( Time Conversion, Grading Students, Apple and Orange ) :
Problem 10: Time Conversion
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
s[0] - '0' represents the tens of hour and s[1] - '0' represents the ones of hour , so hour value can be represented as (s[0] - '0')*10 + (s[1] - '0') . For example: 25 = 2*10 + 5 . To add 12 so that we get the correct format of time we added 10 in its tens value and two in its ones value.
To understand what's this --> string_name[index] - '0' , refer problem 37 i.e seven segment display explanation.
Problem 11: Grading Students
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
This code is simple. There's no need for any explanation.
Problem 12: Apple and Orange
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
This code is simple. There's no need for any explanation.
Guys , if you have any queries related to a question or need more explanation for a question , comment below!
Comments
Post a Comment