Problem 1477 · Medium

Find Two Non-overlapping Sub-arrays Each With Target Sum

Scan prefix sums while remembering the shortest target-sum window that ends before each position, then pair each window with the best window before it.

Open the interactive visualisation