Split an array when meets a certain number?

Hello I need to return count of chunks in given array of numbers.

Chunk can be defined assequence of one or more numbers separated by one or more zeroes.

Example: array [5, 4, 0, 0, -1, 0, 2, 0, 0] contains 3 chunks

so the answer should be 3 since the array can be split into three chunks.

Can you help me with the solution to this one?

Ive looped through the array but dont know how to deal with the multiple zeros.



from Recent Questions - Stack Overflow https://ift.tt/2ZCbEdq
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations