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
4mo
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...
Microsoft Corporation Software Developer Intern interview questions & answers
A Software Developer Intern was asked 7mo agoQ. What were your responsibilities during your internship?
A Software Developer Intern was asked 7mo agoQ. What is the difference between polymorphism and inheritance?
A Software Developer Intern was asked 9mo agoQ. Given a string, reverse the order of characters using standard data structures a...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked 6mo agoQ1. What were your responsibilities during your internship?
A Software Developer Intern was asked 6mo agoQ2. What is the difference between polymorphism and inheritance?
A Software Developer Intern was asked 8mo agoQ3. Given a string, reverse the order of characters using standard data structures a...read more
>
Microsoft Corporation Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

