Largest Divisibility Test
Medium Accuracy: 60.12% Submissions: 228 Points: 4

Babul’s favourite number is 17. He likes the numbers which are divisible by 17. This time what he does is that he takes a number n and tries to find the largest number which is divisible by 17, by rearranging the digits. As the number increases he gets puzzled with his own task. So you as a programmer have to help him to accomplish his task.

Note: If the number is not divisible by rearranging the digits, then return “Not Possible”. n may have leading zeros.

Example 1:

Input: n = 17
Output: 17
Explanation: 17 is the largest number
which is also divisible by 17.


Example 2:

Input: n = 15
Output: 51
Explanation: 51 is the largest number
which is also divisible by 17.


You dont need to read input or print anything. Complete the function largestDivisible() which takes n as input parameter and returns the largest number which is divisible by 17.

Expected Time Complexity: O(|n|*|n|!), where |n| denoting length of n.
Expected Auxiliary Space: O(1)

Constraints:
1<= n <=1010

We are replacing the old Disqus forum with the new Discussions section given below.

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:  