I have N numbers and I want to sort each number by digit. ( In my original problem I want to make the largest number by these (greedy approach)) For ex - If we have 5 numbers 9 1000 845 8000 56 In first step I will pick 9 as 9 is the highest of all 1st digit of numbers
In second step ( as 9 is already picked), next highest first digit is 8, but when 2 or more numbers have same digit I will compare their next digit so I will pick 845.
In this if I sort I will get the following result 9 845 8000 56 1000.
My question is how can implement this in c++ ?
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire