Problem Description
source: https://uva.onlinejudge.org/external/106/10684.html
Solving Technique:
This is a maximum subarray summation related problem. We have to find the maximum subarray from a one-dimensional array and sum-up all values of sub array then we will get the patterns of consecutive wins that will give maximum benefit and elaborate a win-win strategy.
Using Kadane’s algorithm we can solve in O(n) time.
Kadane’s Algorithm:
source: https://uva.onlinejudge.org/external/106/10684.html
Solving Technique:
This is a maximum subarray summation related problem. We have to find the maximum subarray from a one-dimensional array and sum-up all values of sub array then we will get the patterns of consecutive wins that will give maximum benefit and elaborate a win-win strategy.
Using Kadane’s algorithm we can solve in O(n) time.
Kadane’s Algorithm: