C++ || 100% || Swap and Sort
Approach:\n Convert long long to string. (Remember to store only digit not sign i.e. Not \'-\')\n Here 2 cases possible:\n\t If the number is positive, then sor
**Approach:**\n* Convert long long to string. (**Remember to store only digit not sign i.e. Not \'-\'**)\n* Here 2 cases possible:\n\t* If the number is positive, then sort in Ascending Order.\n\t* Else sort in descending. (***Because for Negative numbers Largest absolute value is the Smallest***)\n* Find the First Non-Zero element and swap that number with the first string. This is done because we don\'t want numbers starting with zero.\n* Convert string to long long using stol function.\n* Return the answer according to the sign.\n\n**C++ Code:**\n```\nlong long smallestNumber(long long num) {\n        string s = to_string(abs(num));\n        if(num >= 0){\n            sort(s.begin(), s.end());\n        }else{\n            sort(s.begin(), s.end(), greater<char>());\n        }        \n        if(num > 0){\n            int indx = s.find_first_not_of(\'0\');\n            swap(s[0], s[indx]);\n        }\n        \n        long long ans = stol(s);\n        if(num < 0)\n            ans = -ans;\n        return ans;        \n    }\n```\n**Time:** O(N) \n**Space:** O(1) \n**Examples with Picture:**\n![image](https://assets.leetcode.com/users/images/1173d742-e2d8-4c68-af6b-3ff84353333b_1644170382.9836884.png)\n![image](https://assets.leetcode.com/users/images/1dda11bf-a4f7-4c40-b622-8807fcc9cead_1644170394.6463697.png)\n
[]