Prefix Target Index
Find the smallest index where the running sum hits your target exactly.
Returns the first i where the sum of arr[0..i] equals the target, or -1 if no prefix sum matches — O(n) single pass, no extra space.
Array (comma-separated, non-negative integers)
Target sum
Result
—
Enter an array and target above.