JAVA 100% faster
\nclass Solution {\n    public int subtractProductAndSum(int n) {\n        int temp = n, a = temp % 10, b = temp % 10;\n        temp /= 10;\n        while (temp
```\nclass Solution {\n    public int subtractProductAndSum(int n) {\n        int temp = n, a = temp % 10, b = temp % 10;\n        temp /= 10;\n        while (temp > 0) {\n            int res = temp % 10;\n            a *= res;\n            b += res;\n            temp /= 10;\n        }\n        return a - b;\n    }\n}\n```
['Java']