Problem 731. Given a window, how many subsets of a vector sum positive
Given a vector:
[1 0 -1 3 2 -3 1]
and a window of 2,
A sliding window would find:
1 + 0 = 1 0 - 1 = -1 -1 + 3 = 2 3 + 2 = 5 2 - 3 = -1 -3 + 1 = -2
Meaning that three of the windows were positive.
Given a vector and a window, how many of the windows sum to be positive, not zero or negative?
Solution Stats
Problem Comments
-
5 Comments
I think test suite 3 produces 4 positives, not 3.
I agree with the above comments
Oops. Fixed. thank you.
Test suite 3 doesn't seem to be correct. Total windows possible in this case is 2. How can number of positive windows be greater than that. Someone please clarify.
cool
Solution Comments
Show commentsProblem Recent Solvers851
Suggested Problems
-
1105 Solvers
-
Check if number exists in vector
11531 Solvers
-
Change the sign of even index entries of the reversed vector
536 Solvers
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
1752 Solvers
-
The sum of the numbers in the vector
594 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!