chore: merge "repulling all together (#694)"

* Create slidingWindow.js

* Rename slidingWindow.js to SlidingWindow.js

* update the commit
This commit is contained in:
Mor Mordechai Ben
2021-09-22 19:10:45 +03:00
committed by GitHub
parent 32359498ee
commit 3cae80e456
2 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import { slidingWindow } from '../SlidingWindow'
test('expect to return the largest sum of sequence in the array', () => {
const sum = slidingWindow([1, 2, 5, 2, 8, 1, 5], 2)
expect(sum).toBe(10)
})
test('expect to return the largest sum of sequence in the array', () => {
const sum = slidingWindow([5, 2, 6, 9], 3)
expect(sum).toBe(17)
})
test('expect to return null when the sequence size is larger then the array length', () => {
const sum = slidingWindow([1, 2, 5, 2, 8, 1, 5], 15)
expect(sum).toBe(null)
})