Plus Minus

  • + 1 comment

    For Java 7 / 8, all the tests pass but then, I see this message:

    We couldn't process your submission. Please try to submit your code again.

        public static void plusMinus(List<Integer> arr) {
        
            double posCnt = 0;
            double negCnt = 0;
            double zeroCnt = 0;
            
            for (int num : arr) {
                if (num > 0) {
                    posCnt++;
                } else if (num < 0) {
                    negCnt++;
                } else {
                    zeroCnt++;
                }
            }
            
            System.out.println(String.format("%6f", posCnt / arr.size()));
            System.out.println(String.format("%6f", negCnt / arr.size()));
            System.out.println(String.format("%6f", zeroCnt / arr.size()));
    
        }
    
    }