let's suppose we have A of length 50 rows

how we can calculate the maximum range of non-zeros element and as well as minimum

A = [0 0 1 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 ]

In this case Max and Min should be,

Max = 5

Min = 2

Is there a straightforward solution to do this? without using complex looping because in my case data is too large approximately length of A is 220079705, your kind consideration will be highly regarded by all means,

Many Thanks

## Best Answer