feat: add maxConsecutiveOnes implementation (#1285)

This commit is contained in:
Andrea Tota
2023-02-13 12:41:28 +01:00
committed by GitHub
parent 55c18aef69
commit 5ce828b3fe
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import { maxConsecutiveOnes } from '../MaxConsecutiveOnes.js'
describe('maxConsecutiveOnes', () => {
it('expects to return 0 when argument is empty array', () => {
expect(maxConsecutiveOnes([])).toBe(0)
})
it('expects to return 3', () => {
expect(maxConsecutiveOnes([1, 1, 0, 1, 1, 1])).toBe(3)
})
it('expects to return 2', () => {
expect(maxConsecutiveOnes([1, 0, 1, 1, 0, 1])).toBe(2)
})
it('expects to return 5', () => {
expect(maxConsecutiveOnes([0, 1, 1, 1, 1, 1, 0, 0, 1, 0])).toBe(5)
})
})