[HAI] open lesson maxSum

sliding window fixed size
This commit is contained in:
2024-11-10 20:40:48 +03:00
parent 052a872f46
commit 427731f797
3 changed files with 39 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
import { describe, it, expect } from "vitest";
import { maxSum } from "./maxSum.ts";
describe("maxSum", () => {
it("[3, 2, 5, 9, 4 ,1] k=3 answer 18", () => {
const NUMS = [3, 2, 5, 9, 4, 1];
expect(maxSum(NUMS, 3)).toBe(18);
});
it("[0, 1, 2, 8, 1 ,11, 10, 0, 0 ,5] k=4 answer 18", () => {
const NUMS = [0, 1, 2, 8, 1, 11, 10, 0, 0, 5];
expect(maxSum(NUMS, 4)).toBe(30);
});
});