Easy Solution || C++
Intuition\nThe problem seems to involve manipulating the digits of a given integer to calculate the product and sum of those digits, separately. After obtaining
# Intuition\nThe problem seems to involve manipulating the digits of a given integer to calculate the product and sum of those digits, separately. After obtaining the product and sum, the result is the difference between the product and the sum.\n\n# Approach\nThe approach here is to iterate through the digits of the given number while updating the product and sum. For each iteration, we extract the last digit (n % 10) and update the product and sum accordingly. We then remove the last digit by dividing the number by 10. Finally, we return the difference between the product and the sum.\n\n# Complexity\n- Time complexity: $$O(\\log(n))$$ - The loop runs for the number of digits in the input integer.\n- Space complexity: $$O(1)$$ - The space used is constant, as we only need a few variables regardless of the input size.\n\n# Code\n```cpp\nclass Solution {\npublic:\n    int subtractProductAndSum(int n) {\n        int prod = 1;\n        int sum = 0;\n        while (n) {\n            prod *= (n % 10);\n            sum += (n % 10);\n            n /= 10;\n        }\n        return prod - sum;\n    }\n};\n```
['Math', 'C++']