C++ easy solution.
\n# Complexity\n- Time complexity:0 ms.\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: 5.9 Mb.\n Add your space complexity here, e.g. O(n) \
\n# Complexity\n- Time complexity:0 ms.\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: 5.9 Mb.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int subtractProductAndSum(int n) {\n        int sum=0,s=1;\n        while(n!=0){\n            sum+=n%10;\n            s*=n%10;\n            n/=10;\n        }\n        return s-sum;\n    }\n};\n```
['C++']