[HAI] week3 two pointers squares of a sorted array

https://leetcode.com/problems/squares-of-a-sorted-array/
This commit is contained in:
2024-12-05 10:29:04 +03:00
parent 78b50806e3
commit f16f797381
4 changed files with 68 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import { describe, it, expect } from "vitest";
import { sortedSquares } from "./sortedSquares.ts";
describe("sortedSquares", () => {
it("[-4,-1,0,3,10] => [0,1,9,16,100]", () => {
expect(sortedSquares([-4, -1, 0, 3, 10])).toEqual([0, 1, 9, 16, 100]);
});
it("[-7,-3,2,3,11] => [4,9,9,49,121]", () => {
expect(sortedSquares([-7, -3, 2, 3, 11])).toEqual([4, 9, 9, 49, 121]);
});
});