Doubt/Suggestion regarding problem "Form Biggest Number"

I am unable to solve the question called “Form Biggest Number”

Link : https://hack.codingblocks.com/contests/c/537/1291

I have approached the problem and came up with the following solution:

  1. Find all the permutations of string
  2. For each permutation of string:
    a. Compare whether the current permutation of string is greater than last permutation
    i. If greater then : assign max to current permutation of string

I am compairing two strings by lopping through each string and converting each character to int and compairing them.

This algo/steps is giving me wrong answer. Can you suggest what I am doing wrong here ?

Thanks

You don’t need to find all the permutations of the string at all.
Make use of bubble sort kind of algorithm, where you need to sort the numbers only when the new number is greater than the previous.

Make some compare function which will tell you if you need to swap the numbers or not in the bubble sort.

You’ll also need to convert the string to number so that you can compare accordingly.