Minimum Subarray with Required Sum Problem Statement
Given an array of positive integers ARR
and an integer X
, determine the minimum length subarray where the sum of its elements is strictly greater than X
.
Note:
A subarray is a contiguous block of elements. If multiple subarrays qualify, return the earliest one. If no such subarray exists, return an empty line.
Example:
Input:
ARR = [1, 2, 3, 4, 5], X = 11
Output:
4 5
Explanation:
Subarray [4, 5]
has a sum of 9, which is the minimal subarray with a sum greater than 11.
Constraints:
1 ≤ N ≤ 5 * 105
1 ≤ X ≤ 109
1 ≤ ARR[i] ≤ 109
- Time Limit: 1 sec

AnswerBot
7d

Find the minimum length subarray with sum greater than X in a given array.
Iterate through the array while maintaining a sliding window to find the subarray with sum greater than X.
Keep track of the mi...read more

Help your peers!
Add answer anonymously...
Top Microsoft Corporation Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in Microsoft Corporation Software Developer Intern
>
Microsoft Corporation Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app