Statistics

Problem Statement for "RepresentNumber"

Problem Statement

You have some digits, and you want to use one or more of them to create the largest possible number. The number must have no extra leading zeroes, and no two adjacent digits can be the same. For example, "0121" and "2110" are not valid numbers.

You are given a int[] digits containing exactly 10 elements. The i-th element (0-based) is the number of digit i that you have. Return a String denoting the maximum valid number you can create.

Definition

Class:
RepresentNumber
Method:
maximumNumber
Parameters:
int[]
Returns:
String
Method signature:
String maximumNumber(int[] digits)
(be sure your method is public)

Constraints

  • digits will contain exactly 10 elements.
  • Each element of digits will be between 0 and 50, inclusive.
  • The sum of the elements of digits will be between 1 and 50, inclusive.

Examples

  1. {3,0,0,0,0,0,0,0,0,0}

    Returns: "0"

  2. {4,1,2,0,0,0,0,0,0,0}

    Returns: "202010"

  3. {4,1,8,0,0,0,0,0,0,0}

    Returns: "21202020202"

    You can't use all the '2' digits.

  4. {4,2,0,1,2,0,1,2,2,3}

    Returns: "98989767430401010"

  5. {1,1,0,1,1,4,3,2,0,0}

    Returns: "7676565453510"

  6. {2,3,1,1,1,1,0,1,1,1}

    Returns: "987543210101"

  7. {0,0,2,1,2,3,1,0,2,3}

    Returns: "98989654545232"

  8. {0,1,4,4,1,4,0,2,2,0}

    Returns: "878754535352323212"

  9. {0,0,2,1,1,3,0,1,0,2}

    Returns: "9795453252"

  10. {4,2,0,3,2,1,2,1,1,2}

    Returns: "989765643430301010"

  11. {5,1,3,0,2,1,0,2,1,1}

    Returns: "9875742040202010"

  12. {2,1,0,2,5,0,3,4,4,2}

    Returns: "98987878767646434341040"

  13. {0,3,3,2,4,4,3,4,1,4}

    Returns: "9897979767656545454343212121"

  14. {0,4,4,5,2,4,3,3,3,1}

    Returns: "98787876565654543232321313121"

  15. {2,4,1,0,2,3,2,2,6,3}

    Returns: "9898987878686545451210101"

  16. {2,1,3,4,0,1,5,3,3,1}

    Returns: "98787876563636363212020"

  17. {1,2,3,1,3,3,2,4,0,2}

    Returns: "979767675454543212120"

  18. {2,3,1,2,2,4,2,2,2,2}

    Returns: "9898767654545353210101"

  19. {3,2,1,2,5,0,6,3,1,1}

    Returns: "987676764646464343201010"

  20. {0,4,2,5,6,0,0,2,4,1}

    Returns: "987878484343434341312121"

  21. {2,2,0,1,6,3,2,2,1,3}

    Returns: "9897976565454341414040"

  22. {7,3,4,2,7,1,1,2,2,10}

    Returns: "989897979695949494943434240202020101010"

  23. {4,5,2,1,0,3,3,2,4,6}

    Returns: "989898989797656565321210101010"

  24. {5,4,4,8,1,3,4,4,4,2}

    Returns: "989878787676565654323232323131030301010"

  25. {7,2,1,4,5,4,4,3,4,2}

    Returns: "989878787656565654343430404030201010"

  26. {5,2,4,5,5,3,4,2,4,2}

    Returns: "989878786565656434343434321020202010"

  27. {6,1,3,1,3,1,5,2,8,4}

    Returns: "9898989878786868656464304020202010"

  28. {3,1,2,5,4,6,4,2,5,1}

    Returns: "987878686865654545454532323103030"

  29. {3,0,6,4,5,3,4,3,3,2}

    Returns: "989878767656565434343424232020202"

  30. {1,4,3,2,2,3,5,1,2,7}

    Returns: "989897969696965654543231212101"

  31. {7,4,1,2,1,1,4,4,4,4}

    Returns: "98989898767676765430302010101010"

  32. {4,6,6,1,7,0,3,5,4,6}

    Returns: "989898989797676767434242424242412101010101"

  33. {3,5,4,7,7,6,5,7,2,3}

    Returns: "9898976767676767575454545454343432323232131010101"

  34. {2,5,7,3,3,8,2,6,1,4}

    Returns: "98979797676757545454535353521212121212020"

  35. {6,8,3,4,4,5,3,5,7,3}

    Returns: "989898787878787656565454543432323121010101010101"

  36. {8,3,5,7,3,2,5,7,3,4}

    Returns: "98989897676767676757543434323232030302020101010"

  37. {4,7,4,3,4,8,10,4,0,2}

    Returns: "9797676765656565656565654343434212121210101010"

  38. {7,7,2,8,3,5,4,2,3,5}

    Returns: "9898989797656565654543432323131310303010101010"

  39. {4,5,2,6,5,2,7,2,4,4}

    Returns: "98989898767656564646464343232313130101010"

  40. {4,4,3,8,6,6,3,4,1,5}

    Returns: "98979797976565654545454343432323231310301010"

  41. {2,5,5,7,3,2,9,3,5,2}

    Returns: "9898787878656564646463636363232323121210101"

  42. {9,12,9,3,2,3,3,4,2,3}

    Returns: "98989767676754545323232121212121202010101010101010"

  43. {5,7,16,1,3,5,3,6,2,2}

    Returns: "98987676767575754542524232121212121212120202020202"

  44. {8,9,11,4,3,1,6,1,3,4}

    Returns: "98989897656464646363232321212121212020202010101010"

  45. {9,10,8,4,4,2,3,5,3,2}

    Returns: "98987876767675454343432321212121202020101010101010"

  46. {9,11,15,0,2,0,3,5,2,3}

    Returns: "98989767676747421212121212121212102020202020201010"

  47. {13,10,13,3,1,2,3,2,1,2}

    Returns: "98976765654323232121212120202020202020101010101010"

  48. {1,30,4,2,4,1,2,3,1,2}

    Returns: "19191817171716161514141414131312121212101"

  49. {14,3,1,2,0,3,1,5,3,1}

    Returns: "987878070707060505050303020101010"

  50. {11,12,10,1,2,2,3,4,1,4}

    Returns: "98979797676565434212121212121020202020101010101010"

  51. {10,10,13,2,0,5,5,3,2,0}

    Returns: "87876765656565353212121212121210202020202020101010"

  52. {2,0,0,3,1,1,3,3,36,1}

    Returns: "89878787868686858483838380808"

  53. {2,2,1,1,2,2,3,1,31,5}

    Returns: "898989898987868686858584848382818180808"

  54. {0,0,1,1,2,1,2,0,40,3}

    Returns: "898989868685848483828"

  55. {2,5,4,2,2,1,0,1,32,1}

    Returns: "8987858484838382828282818181818180808"

  56. {2,3,0,0,2,1,1,2,13,2}

    Returns: "98987878685848481818180808"

  57. {2,3,0,0,2,1,1,2,14,2}

    Returns: "898987878685848481818180808"

  58. {0,25,24,0,0,0,0,0,0,0}

    Returns: "1212121212121212121212121212121212121212121212121"

  59. {50,0,0,0,0,0,0,0,0,0}

    Returns: "0"

  60. {0,50,0,0,0,0,0,0,0,0}

    Returns: "1"

  61. {0,0,0,0,0,0,0,0,0,50}

    Returns: "9"

  62. {5,5,5,5,5,5,5,5,5,5}

    Returns: "98989898987676767676545454545432323232321010101010"

  63. {25,24,0,0,0,0,0,0,0,0}

    Returns: "101010101010101010101010101010101010101010101010"

  64. {0,25,23,0,0,0,0,0,0,0}

    Returns: "12121212121212121212121212121212121212121212121"

  65. {25,23,0,0,0,0,0,0,0,0}

    Returns: "1010101010101010101010101010101010101010101010"

  66. {49,1,0,0,0,0,0,0,0,0}

    Returns: "10"

  67. {0,49,1,0,0,0,0,0,0,0}

    Returns: "121"

  68. {32,5,4,2,2,1,0,1,2,1}

    Returns: "908080705040403030202020201010101010"

  69. {14,3,0,0,2,1,1,2,2,2}

    Returns: "90908080707060504040101010"

  70. {13,3,0,0,2,1,1,2,2,2}

    Returns: "90908080707060504040101010"


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: