Odd Even Count
JavaScript
Easy
3 views
Problem Description
Given n numbers, count how many are odd and how many are even. Print as: oddCount evenCount.
Input Format
Line1: n. Line2: n integers.
Output Format
Two integers: odd even.
Official Solution
const fs=require('fs');const a=fs.readFileSync(0,'utf8').trim().split(/\\s+/);if(!a[0])process.exit(0);let i=0;const n=Number(a[i++]);let odd=0,even=0;for(let j=0;j<n;j++){const v=BigInt(a[i++]);if(v%2n===0n)even++;else odd++;}process.stdout.write(odd+' '+even);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!