feat: move corpus to library

This commit is contained in:
alexm committed 2026-10-06 09:57:04 -04:00
1 parent df12b2a008
commit 9d351b4a0f
1301 files changed
+941859 -4

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
// Kadane: find the best, with an early return for the empty case.
// EXPECT: 6
// EXPECT: -1
FUNCTION MAX_SUBARRAY(Xs : LIST OF INTEGER) RETURNS INTEGER
REQUIRE LENGTH(Xs) >= 1
DECLARE Best, Here : INTEGER
Best <- Xs[0]
Here <- Xs[0]
FOR I <- 1 TO LENGTH(Xs)
Here <- MAX(Xs[I], Here + Xs[I])
Best <- MAX(Best, Here)
NEXT I
RETURN Best
ENDFUNCTION
OUTPUT MAX_SUBARRAY([-2, 1, -3, 4, -1, 2, 1, -5, 4])
OUTPUT MAX_SUBARRAY([-1])