package leetcode;

/**
 * https://leetcode.com/problems/sign-of-the-product-of-an-array/
 */
public class Problem1822 {
    public int arraySign(int[] nums) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1822 prob = new Problem1822();
        System.out.println(prob.arraySign(new int[]{-1,-2,-3,-4,3,2,1})); // 1
        System.out.println(prob.arraySign(new int[]{1,5,0,2,-3})); // 0
        System.out.println(prob.arraySign(new int[]{-1,1,-1,1,-1})); // -1
    }
}

@@ -164,357 +164,400 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1822 prob = new Problem1822();%0A        System.out.println(prob.arraySign(new int%5B%5D%7B-1,-2,-3,-4,3,2,1%7D)); // 1%0A        System.out.println(prob.arraySign(new int%5B%5D%7B1,5,0,2,-3%7D)); // 0%0A        System.out.println(prob.arraySign(new int%5B%5D%7B-1,1,-1,1,-1%7D)); // -1
+int answer;%0A        if (nums%5B0%5D %3C 0) %7B%0A            answer = -1;%0A        %7D else if (nums%5B0%5D == 0) %7B%0A            return 0;%0A        %7D else %7B%0A            answer = 1;%0A        %7D%0A        for (int i = 1; i %3C nums.length; i++) %7B%0A            if (nums%5Bi%5D %3C 0) %7B%0A                answer *= -1;%0A            %7D else if (nums%5Bi%5D == 0) %7B%0A                return 0;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1822