[C++] 100% fast, easy to understand
\nclass Solution {\npublic:\n    int subtractProductAndSum(int n) {\n        int prod=1,sum=0,ans=0;\n        while(n!=0){\n            sum+=n%10;\n            
```\nclass Solution {\npublic:\n    int subtractProductAndSum(int n) {\n        int prod=1,sum=0,ans=0;\n        while(n!=0){\n            sum+=n%10;\n            prod*=n%10;\n            n/=10;\n        }\n        ans=prod-sum;\n        return ans;\n    }\n};\n```
['C++']