ocaml: phase 5.1 trapping_rain.ml baseline (LeetCode trapped water = 6)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Classic trapped-rain-water two-pass DP:
left_max[i] = max(heights[0..i]) (forward sweep)
right_max[i] = max(heights[i..n-1]) (downto sweep)
water = sum over i of (min(left_max[i], right_max[i])
- heights[i])
For [0; 1; 0; 2; 1; 0; 1; 3; 2; 1; 2; 1]: water = 6.
Tests dual sweep (forward + downto), array of running maxes,
inline-if rhs of <- for running-max update (uses iter-236 fix
for <- accepting if/match RHS).
203 baseline programs total.
This commit is contained in:
@@ -407,6 +407,12 @@ _Newest first._
|
||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||
recursive match, List.append, List.fold_left.
|
||||
- 2026-05-11 Phase 5.1 — trapping_rain.ml baseline (trapped rain
|
||||
water over heights [0;1;0;2;1;0;1;3;2;1;2;1] = 6). Left-max and
|
||||
right-max prefix arrays; at each index water = min(L,R) − h.
|
||||
Tests dual sweep (forward + downto), array of running maxes,
|
||||
inline-if rhs of `<-` for running-max update (uses iter-236
|
||||
fix). 203 baseline programs total.
|
||||
- 2026-05-11 Phase 5.1 — gas_station.ml baseline (find unique start
|
||||
station for circular gas tour, gas=[1;2;3;4;5] cost=[3;4;5;1;2]
|
||||
→ start at index 3). Classic O(n) greedy: walk once tracking the
|
||||
|
||||
Reference in New Issue
Block a user