Given a one-dimensional array, write a function that returns the length of the longest sequence of 1s. The array consists of integers, and it contains only 1s and 0s.
The function receives as input the array.
1 | 0 | 0 | 1 | 1 | 1 | 1 |
---|
should return 4
1 | 0 | 0 | 0 | 1 | 0 | 1 |
---|
should return 1
0 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
should return 0
0 | 1 | 1 | 1 | 1 | 1 | 1 |
---|
should return 6
0 | 1 | 1 | 1 | 0 | 1 | 1 |
---|
should return 3
What are the differences between linked lists
and arrays
?
Write a function that returns the n-th
fibonacci number. n
is provided as input to the function