✅ C++ || Sort and Erase || East Understanding
\uD83D\uDC68\u200D\uD83D\uDCBB Friend\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that motivates me to create a better post li
\uD83D\uDC68\u200D\uD83D\uDCBB Friend\'s if you find this solution helpful \uD83D\uDE0A, PLEASE do UPVOTE. By doing that motivates me to create a better post like this \u270D\uFE0F\n____________________________________________________________________________________________________________\n____________________________________________________________________________________________________________\n\n#### \u2714\uFE0F **Question Conclusion**\n* Make the number given number smallest\n#### \u2714\uFE0F **Solution - I (Best Approach)**\n##### **Intuition :-**\n* convert integer into string and Sort and Erase.\n##### **Code :-**\n```\nclass Solution\n{\npublic:\n    long long smallestNumber(long long num)\n    {\n        if (num < 0)\n        {\n            string s = to_string(-num);\n            sort(s.rbegin(), s.rend());\n            return -stoll(s);\n        }\n        else if (num == 0)\n            return 0;\n        string s = to_string(num);\n        sort(s.begin(), s.end());\n        int i = 0;\n        while (s[i] == \'0\')\n            i++;\n        char c = s[i];\n        s.erase(s.begin() + i);\n        s = c + s;\n        return stoll(s);\n    }\n};\n```\n_____________________________________________________________________________________________________________\n_____________________________________________________________________________________________________________\n\n\uD83D\uDCBBIf there are any suggestions/questions in my post, comment below \uD83D\uDC47
['String', 'C', 'Sorting', 'C++']