How do I find a maximum number of consecutive non-zero values in the array?

It is important to consider edge cases.

  • Is the array guaranteed to contain at least one element? If it can be empty, be sure that this will not cause your function to fail.
  • Also make sure that the function can handle an array that contains only zeroes.
1 Like