mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-14 01:22:58 +08:00
chore: merge "repulling all together (#694)"
* Create slidingWindow.js * Rename slidingWindow.js to SlidingWindow.js * update the commit
This commit is contained in:

committed by
GitHub

parent
32359498ee
commit
3cae80e456
16
Search/test/SlidingWindow.test.js
Normal file
16
Search/test/SlidingWindow.test.js
Normal 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)
|
||||
})
|
Reference in New Issue
Block a user