Count Nulls

EasyData EngineeringArray

Description

Given an array that may contain null entries, return how many of its entries are null.

Examples

Input:[1,null,2,null,null]
Output:3
Explanation:

Scanning the array and tallying the missing entries gives how many nulls it holds.

Input:[1,2,3]
Output:0
Explanation:

Scanning the array and tallying the missing entries gives how many nulls it holds.

Input:[null,null]
Output:2
Explanation:

Scanning the array and tallying the missing entries gives how many nulls it holds.

Constraints

  • 0 ≤ length ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.