Count positives and negatives
Java
Easy
4 views
Problem Description
Task: return [posCount, negCount, zeroCount] for the array.
Output Format
Return value
Official Solution
static int[] countSigns(int[] a){int p=0,n=0,z=0;for(int x:a){if(x>0) p++; else if(x<0) n++; else z++;}return new int[]{p,n,z};}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!