Want to solve this problem? Login now to get access to solve the problems
Line 1: Linked list elements of length n (separated by space and terminated by -1)
The maximum Number formed using the digits present in the linked list.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= N <= 10^6
0 <= data <= 9
where N is the size of linked list and data is the value of a node in the linked list.
Time Limit: 1sec
1 2 2 0 9 -1
92210
The digits that are present in the linked list are : (1, 2, 2, 0, 9 )
So the answer is the maximum of all the numbers that are formed using these digits is 92210.
1 0 0 0 3 -1
31000
The maximum of all the numbers formed using the digits present in the linked list i.e.(1, 0, 0, 0, 3) is 31000.