18. Count Ones

Given an integer array nums. Write a function int FindOnesCount(int[] nums) that returns the number of ones in the array.
Example 1
Input: nums = [1, 1, 2, 3]
Output: 2
Explanation: The array contains two ones at indices 0 and 1
Example 2
Input: nums = [0, 5, 7, 9]
Output: 0
Explanation: There are no ones in the array
Example 3
Input: nums = [1, 1, 1, 1]
Output: 4
Explanation: All array elements equal 1
arrayseasy
JavaScript
Loading...
Line 1, Char 1