Given an integer array nums and an integer target, implement:
(
-
a function that returns true if any non-empty contiguous subarray sums to target;
(
-
a function that returns the number of contiguous subarrays whose sum equals target;
(
-
assuming all numbers in nums are non-negative, design an O(n) time, O(
-
extra-space method to find one such subarray (return its start and end indices) and explain how to adapt it to count all such subarrays. For
(
-
and
(
-
also aim for O(n) time. Discuss trade-offs, edge cases (e.g., zeros, negative numbers, large inputs), and prove correctness.