Statistics

Problem Statement for "BusyHours"

Problem Statement

An airline freight sorting hub is serviced by several planes. Given each plane's flight schedule, determine the busiest hour of the day when the number of planes at the hub is the highest, and the least loaded hour of the day, when the number of planes at the hub is the lowest. In cases when multiple such hours exist, pick the earliest ones.

Each element of schedule has 24 characters, and represents an hour-by-hour schedule of one plane. Each position in the string corresponds to an hour of the day; '1' (one) and '0' (zero) are the only characters allowed in the strings. When position X in the string contains '1', the plane is at the hub at the hour X; when the character is '0', the plane is not at the hub at that hour.

Definition

Class:
BusyHours
Method:
minMaxLoad
Parameters:
String[]
Returns:
int[]
Method signature:
int[] minMaxLoad(String[] schedule)
(be sure your method is public)

Constraints

  • schedule contains between 1 and 50 elements, inclusive
  • Elements of schedule are exactly 24 characters in length
  • Elements of schedule do not contain characters other than '0' (zero) and '1' (one).

Examples

  1. {"010101010101010101010101", "101010101010101010101010"}

    Returns: { 0, 0 }

  2. {"010101010101010101010101", "010101010101010101010101"}

    Returns: { 0, 1 }

  3. {"110000000000001100000001", "110000000001111100000000", "000111110000000111100000"}

    Returns: { 2, 15 }

  4. {"110000000000001100000001", "110000000001111100000000", "000111110000000111100000", "000000000011110000000111", "111111100001111100000111", "100111110000000111100100"}

    Returns: { 8, 15 }

  5. {"110000000000001100000001", "110000000001111100000000", "000111110000000111100000", "000000000011110000000111", "111111100001111100000111", "100111110000000111100100", "110000000000001100000001", "110000000001111100000000", "000111110000000111100000", "000000001111110000000111", "111111100001111100000111", "100111110000000111100100"}

    Returns: { 19, 15 }

  6. {"110000000000001100000001", "110000000001111100000000", "000111110000000111100000", "000000000011110000000111", "111111100001111100000111", "100111110000000111100100", "110000000000001100000001", "110000000001111100000000", "000111110000000111100000", "000000000011110000000111", "111111100001111100000111", "100111110000000111100100", "110000000000001100000001", "110000000001111100000000", "000111110000000111100000", "000000001011110000000111", "111111100001111100000111", "100111110000000111100100"}

    Returns: { 9, 15 }

  7. {"000000000000000000000001", "100000000000000000000001", "000000000000000000000001", "000000000000000000000001"}

    Returns: { 1, 23 }

  8. {"101010101010101010101010", "101010101010101010101010", "101010101010101010101010"}

    Returns: { 1, 0 }

  9. {"000000000100000000000000"}

    Returns: { 0, 9 }

  10. {"110000000000001100000001", "110000000001111100000000", "000111110000000111100000"}

    Returns: { 2, 15 }

  11. {"000100000000000000000000"}

    Returns: { 0, 3 }

  12. {"111111111111111111111111", "000000110000000000000000"}

    Returns: { 0, 6 }

  13. {"111111111111111111111110"}

    Returns: { 23, 0 }

  14. {"111111111111111111111111", "111111111111111111111111"}

    Returns: { 0, 0 }

  15. {"010101010101010101010101", "101010101010101010101010"}

    Returns: { 0, 0 }

  16. {"111111111111111111111111", "010101010000000000000000"}

    Returns: { 0, 1 }

  17. {"010000000000000000000000", "001000000000000000000000", "010000000000000000000000"}

    Returns: { 0, 1 }

  18. {"111111111111111111111111", "101010101010101010101010"}

    Returns: { 1, 0 }

  19. {"101010101010101010101010"}

    Returns: { 1, 0 }

  20. {"000000000000000000000001", "000000000000000000000001", "000000000000000000000001", "000000000000000000000001"}

    Returns: { 0, 23 }

  21. {"101010101010101010101010", "101010101010101010101010"}

    Returns: { 1, 0 }

  22. {"111111111111111111111111"}

    Returns: { 0, 0 }

  23. {"100000000000000000000001", "010000000000000000000001"}

    Returns: { 2, 23 }

  24. {"111011111111111111111111", "111011111111111111111111"}

    Returns: { 3, 0 }

  25. {"111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111111", "111111111111111111111110"}

    Returns: { 23, 0 }

  26. {"010000000000000000000000", "010000000000000000000000"}

    Returns: { 0, 1 }

  27. {"010101010101010101010101", "101010101010101010101010"}

    Returns: { 0, 0 }

  28. {"101111111111111111111111", "101111111111111111111111", "101111111111111111111111"}

    Returns: { 1, 0 }

  29. {"111111111111111111111111", "111111111111111111111111", "111111111111111111111111"}

    Returns: { 0, 0 }

  30. {"000000000000100000000000"}

    Returns: { 0, 12 }

  31. {"010101010101010101010101", "101010101010101010101010"}

    Returns: { 0, 0 }

  32. {"000000000000000000000000"}

    Returns: { 0, 0 }

  33. {"001111111111111111111111", "001111111111111111111111", "001111111111111111111111"}

    Returns: { 0, 2 }

  34. {"000000000000000000000000"}

    Returns: { 0, 0 }

  35. {"110000000000001100000001", "110000000001111100000000", "000111110000000111100000"}

    Returns: { 2, 15 }

  36. {"111011111111111111111111", "111111111111111111111111"}

    Returns: { 3, 0 }

  37. {"010101010101010101000101", "101010101010101010101011", "101010101010101010101011", "101010101010101010101011"}

    Returns: { 19, 23 }

  38. {"110000000000001000000001", "110000000001110000000000", "000111110000000111100000", "000101010001000100000001", "110000000000001000000001", "110000000001110000000011", "000111010000000111100000", "000101010001000100000001", "100000000000000000000001", "110000000001110001000000", "000111110011100111100000", "000101010001000100000001", "110000000000001000000001", "110000000001010000000000", "000111110000000111100000", "000101010001000100000001", "110000000000001000000001", "110000000001110000000000", "000111110001000111100000", "000101010001000100000001", "110000111100001000000001", "110000000001110000010000", "000111110000000111100000", "000101010001000100010001", "110000000000001000000001", "110000000001110000110000", "000111110000000111100000", "000101010001000100000001", "110000001110001000000001", "110000000001110000000000", "000101110010000111100000", "000101010001000100000001", "110000010101001000000001", "110000000001110001000000", "000110110000000111100000", "000101010001000100100001", "110000010001001000000001", "110001000101110000000000", "000111110000000111100000", "000101010001000100000001", "110000000000001000000001", "110000000001110000000000", "000111110000000111100000", "000101010001000100000001", "110000000000001000000001", "110000000001110000010000", "000111110001000111100000", "000101010001000100000001", "110000000000001000000001", "110000000001110000001000"}

    Returns: { 2, 11 }

  39. {"000100010001000100010001", "000100010001000100010001", "000100010001000100010001", "000100010001000100010001", "000100010001000100010001", "000100010001000100010001", "000100010001000100010001", "000100010001000100010001", "000100010001000100010001", "000100010001000100010001", "000100010001000100010001"}

    Returns: { 0, 3 }

  40. {"010101010101010101010101", "111101010101010101010101"}

    Returns: { 4, 1 }

  41. {"111111111111111111111110", "000000000000000000000001"}

    Returns: { 0, 0 }

  42. {"010101010101010101010101", "101010101010101010101010"}

    Returns: { 0, 0 }

  43. { "110000000000001100000001", "110000000001111100000000", "000111110000000111100000"}

    Returns: { 2, 15 }

    2 is the earliest hour when there are no planes at the hub, and 15 is the busiest hour, when all three planes are at the hub.

  44. { "010101010101010101010101", "101010101010101010101010"}

    Returns: { 0, 0 }

    All hours are equally loaded, and 0 is the earliest of them.

  45. { "010101010101010101000101", "101010101010101010101011", "101010101010101010101011", "101010101010101010101011"}

    Returns: { 19, 23 }


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: