**Not a member of Pastebin yet?**

**, it unlocks many cool features!**

__Sign Up__- Beautiful numbers
- A beautiful number is one divisible by 5, 6 and 8.
- Given an array containing the number of times each digit can be used, find the largest beautiful number that can be formed and return it in RLE compressed version.
- Rules:
- - The digit array contains 10 elements. The element at position i corresponds to the number of times i can be used as a digit in the newly formed number.
- - You do not have to use all available digits.
- - You are not allowed to use extra digits, meaning that the maximum number of occurrences of a digit in the formed number cannot exceed the number in the corresponding position in the digit array.
- - You are not allowed to use leading zeros.
- - RLE encoding replaces each sequence of a same character in a string with the length of a sequence and the character. For example, "111559995" will be encoded as "31253915".
- - If it is impossible to form such number from the given array, return "Impossible".
- Example:
- digits = {3,1,0,0,0,0,0,0,1,0} (Meaning we can use the following numbers: 0,0,0,1,8)
- The largest beautiful number that can be formed is 81000.
- The RLE compressed version of "81000" is "181130".
- Input parameters:
- digits - An array containing the number of times each digit can be used
- Constraints:
- digits will contain 10 elements
- each element will be between 0 and 10 000 000 (inclusive)
- Return value:
- The largest beautiful number in RLE compressed format as a string or "Impossible" if it is not possible to form a beautiful number.
- Class Name:
- BeautifulNumbers
- Method signature:
- public String findLargestBeautifulNumber(int[] digits)
- Test Case 1:
- findLargestBeautifulNumber({1,1,0,1,0,1,0,1,0,1}) = "10"
- Test Case 2:
- findLargestBeautifulNumber({10,1,0,0,0,0,0,0,1,0}) = "1811100"
- Test Case 3:
- findLargestBeautifulNumber({0,0,17,0,18,18,14,0,13,8}) = "Impossible"
- Test Case 4:
- findLargestBeautifulNumber({142,0,0,117,0,27,7,104,0,180}) = "180910477626511731420"

RAW Paste Data