ChatGPT
Explanation:
prefixSumMap maps prefix sums to their
earliest index.
When we find (currSum - k) in the map, it
means the subarray after that index sums to
k.
We update max length and store the
subarrays accordingly.
Output for your input:
r Copy code
Ask anything
Tools
ChatGPT can make mistakes. Check important info. See Cookie
Preferences.