Solution using C++ || Beats 100 %  || easiest solution
Connect to me: https://www.linkedin.com/in/rocky-patel-36070020a/\n Describe your first thoughts on how to solve this problem. \n\n# Approach \n Describe your a
Connect to me: https://www.linkedin.com/in/rocky-patel-36070020a/\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach \n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)      //N= Number of digits in num\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long smallestNumber(long long num) {\n        long long ans=0;\n        vector<long long>a;\n        int j=0;\n       //base case\n        if(num==0) return num;\n       // finding digits from number\n        while(num){\n            int x=num%10;\n            a.push_back(x);\n            num/=10;\n        }\n        sort(a.begin(), a.end());\n        long long n=a.size();\n        /* if num is -ve then we will create largest number */\n        if(num<0){\n            for(int i=0;i<a.size();i++){\n                ans=ans*10+a[n-1-i];  //since vector is sorted and we have to create largest number\n            }\n        }\n        else{\n    /*if num is +ve than we will find smallest digit excluding zero */\n    /*if num = 50001 than smallest num= 10005 */\n            while(a[j]==0) j++;\n            swap(a[0],a[j]);\n            for(int i=0;i<n;i++) ans=ans*10+a[i];\n            \n        }\n        return ans;\n        \n    }\n};\n```
['C++']