BackmediumArrays Infosys

Minimum Sum Subarray Solution

Problem Statement

You are given an array of integers `nums` and a target sum `target`. Find the minimum window subarray that sums up to the `target`. If no such window exists, return an empty array.

Example 1
Input
{"nums":[14203105],"target":33}
Output
[20310]

Explanation: The minimum window subarray that sums up to 33 is [20,3,10]

Example 2
Input
{"nums":[12345],"target":15}
Output
[45123]

Explanation: The minimum window subarray that sums up to 15 is not [4,5], it's [4,5,1,2,3] or [1,2,3,4,5], the statement does not specify if the window has to be continuous, or the smallest window that can sum to the target

Constraints

  • Input array is sorted in non-decreasing order. Target sum may be any positive integer.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free