You are viewing a single comment's thread. Return to all comments →
Here's what I did and it worked.
function main() { var n = parseInt(readLine()); arr = readLine().split(' '); arr = arr.map(Number); var pos = 0; var neg = 0; var zero = 0; for(var i=0; i<arr.length; i++){ if(arr[i] > 0){ pos++; }else if(arr[i] < 0){ neg++; }else{ zero++; } } pos = pos/n; neg = neg/n; zero = zero/n; console.log(pos); console.log(neg); console.log(zero); }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
Here's what I did and it worked.