548.Convert Seconds to Hours, Minutes and Seconds
Easy
Given a number of seconds
total, return it as [hours, minutes, seconds], where minutes and seconds are each below 60.
An algorithmAlgorithmA finite, precise sequence of steps that turns an input into the correct output. is just a clear recipe that always finishes with the right answer. This problem has two perfectly valid recipes: repeatedly take away an hour or a minute, or divide once. Both are correct, but they need very different amounts of work as the input grows — the idea behind everything else in this section.
Example 1:
Input: total = 3725
Output: [1,2,5]
Example 2:
Input: total = 59
Output: [0,0,59]
+ 5 hidden test cases run on Submit.
Constraints:
- ●
0 ≤ total ≤ 1000000
total =
3725