package leetcode;

/**
 * https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/
 */
public class Problem1281 {
    public int subtractProductAndSum(int n) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1281 prob = new Problem1281();
        System.out.println(prob.subtractProductAndSum(234)); // 15
        System.out.println(prob.subtractProductAndSum(4421)); // 21
    }
}

@@ -192,38 +192,50 @@
     
-// TODO%0A        return
+int product = 1;%0A        int sum =
  0;%0A    
 %7D%0A%0A 
@@ -234,236 +234,162 @@
     
+ 
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1281 prob = new Problem1281();%0A        System.out.println(prob.subtractProductAndSum(234)); // 15%0A        System.out.println(prob.subtractProductAndSum(4421)); // 21
+   for (char c : Integer.toString(n).toCharArray()) %7B%0A            product *= c - '0';%0A            sum += c - '0';%0A        %7D%0A        return product - sum;
 %0A   

Solve problem 1281