Statistics

Problem Statement for "Time"

Problem Statement

Computers tend to store dates and times as single numbers which represent the number of seconds or milliseconds since a particular date. Your task in this problem is to write a method whatTime, which takes an int, seconds, representing the number of seconds since midnight on some day, and returns a String formatted as "<H>:<M>:<S>". Here, <H> represents the number of complete hours since midnight, <M> represents the number of complete minutes since the last complete hour ended, and <S> represents the number of seconds since the last complete minute ended. Each of <H>, <M>, and <S> should be an integer, with no extra leading 0's. Thus, if seconds is 0, you should return "0:0:0", while if seconds is 3661, you should return "1:1:1".

Definition

Class:
Time
Method:
whatTime
Parameters:
int
Returns:
String
Method signature:
String whatTime(int seconds)
(be sure your method is public)

Constraints

  • seconds will be between 0 and 24*60*60 - 1 = 86399, inclusive.

Examples

  1. 0

    Returns: "0:0:0"

  2. 3661

    Returns: "1:1:1"

  3. 5436

    Returns: "1:30:36"

  4. 86399

    Returns: "23:59:59"

  5. 12345

    Returns: "3:25:45"

  6. 543

    Returns: "0:9:3"

  7. 6547

    Returns: "1:49:7"

  8. 345

    Returns: "0:5:45"

  9. 23334

    Returns: "6:28:54"

  10. 43200

    Returns: "12:0:0"

  11. 36000

    Returns: "10:0:0"

  12. 45678

    Returns: "12:41:18"

  13. 987

    Returns: "0:16:27"

  14. 9999

    Returns: "2:46:39"

  15. 2

    Returns: "0:0:2"

  16. 5436

    Returns: "1:30:36"

  17. 86399

    Returns: "23:59:59"

  18. 3660

    Returns: "1:1:0"

  19. 3600

    Returns: "1:0:0"

  20. 86398

    Returns: "23:59:58"

  21. 60

    Returns: "0:1:0"

  22. 0

    Returns: "0:0:0"

  23. 3661

    Returns: "1:1:1"

  24. 6

    Returns: "0:0:6"

  25. 36

    Returns: "0:0:36"

  26. 2

    Returns: "0:0:2"

  27. 5436

    Returns: "1:30:36"

  28. 86399

    Returns: "23:59:59"

  29. 3660

    Returns: "1:1:0"

  30. 3600

    Returns: "1:0:0"

  31. 86398

    Returns: "23:59:58"

  32. 60

    Returns: "0:1:0"

  33. 0

    Returns: "0:0:0"

  34. 3661

    Returns: "1:1:1"

  35. 6

    Returns: "0:0:6"

  36. 36

    Returns: "0:0:36"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: