Question: One more problem Given an array A of N elements. Find the smallest length of a subarray starting from index / such that the sum
One more problem
Given an array of elements. Find the smallest length of a subarray
starting from indexsuch that the sum of that subarray is positive for
each index from to If there is no such subarray, then the length is
considered to be
Function description
Complete the solve function. This function takes the following
parameters:
: Represents the number of elements
A: Represents the elements of the array
Input format for custom testing
Note: Use this input format if you are testing against custom input or
writing code in a language where we don't provide boilerplate code.
The first line of the indut contains one interiar Nl clanntine the
Output format
Print spaceseparated integers, thi integer denoting the smallest lengths
of subarray starting from with positive sum.
Constraints
AAiin
Sample input
Sample output
Explanation
Given:
Approach:
For index the subarray is with length
For index the subarray is with length
For index the subarray is with length
So answer
Note:
Your code must be able to print the sample output from the provided samplesinput.
However, your code is run against multiple hidden test cases. Therefore, your code
must pass these hidden test cases to solve the problem statement.
Limits
Time Limit: for each input file
Memory Limit: MB
Source Limit: KB
Scoring
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
