0

Counting number of elements excluding nulls?

How can I count the number of elements not includint nulls in a generic array? I know that I can loop until a null is reached , but is there way to count in constant time? I can’t think of a way

13th Sep 2019, 3:30 PM
Jamie Charles
1 Answer
0
Set a counter that only increments inside a loop if the value is != null
13th Sep 2019, 5:05 PM
Dominique Abou Samah
Dominique Abou Samah - avatar