Explanation

569.Count Even and Odd Numbers in an Array

Easy
Given an array nums, return [evens, odds]: how many elements are even and how many are odd. Counting by category is the accumulator pattern with more than one counter. Because every integer is either even or oddComplementary CategoriesTwo groups that together cover everything with no overlap, so knowing one count gives the other., the second count can also be derived from the first — a small example of using a fact about the data to do less work.

Example 1:

Input: nums = [4,7,10,3,0]

Output: [3,2]

Example 2:

Input: nums = [-5,-2]

Output: [1,1]

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ nums.length ≤ 1000
  • ●-1000000 ≤ nums[i] ≤ 1000000

nums =

[4, 7, 10, 3, 0]