🚀BEgiNner 🥰FriENdLy🙌  | |   ✅💯100% Beats  | |  🥰 Easy🧠
Intuition\nthere are two solns available \n Describe your first thoughts on how to solve this problem. \n\n# Approach\nThe approach to solving this problem invo
# Intuition\nthere are two solns available \n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nThe approach to solving this problem involves converting the given integer n into its individual digits, calculating the product and sum of those digits, and then finding the difference between the product and sum.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: **O(log(N))**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:  **O(log(N))**\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int subtractProductAndSum(int n) {\n        String num = Integer.toString(n);\n        int [] dgt = new int[num.length()];\n\n        for(int i=0; i<num.length(); i++){\n            dgt[i] = Character.getNumericValue(num.charAt(i));\n        }\n\n        int pdt = 1;\n        int sum = 0;\n        for(int e : dgt){\n            pdt*=e;\n            sum+=e;\n        }\n        return pdt-sum;\n\n\n\n        /*int sum =0;\n        int pdt = 1;\n        while(n>0){\n            sum = (n%10)+sum;\n            pdt = (n%10)*pdt;\n            n/=10;\n        }\n        return pdt-sum;*/\n    \n     }\n}\n```\n![cat2.jpeg](https://assets.leetcode.com/users/images/fd3f1fa6-8b8a-41cb-90c4-0cddfb5a5dfe_1701752952.8748214.jpeg)\n
['Java']