Below code gives output as 32 while testing, but the expected output must be 20 instead of 32. What could be wrong here?. I am trying to find the largest sum of vector {5, 9, 7, 11} is sum of elements 9 and 11, which is 20.
do you mean to say to just use only curr = numbers[i]; and eliminate the remaining loop in the code? Instead of using if loop, should i restrict myself to just use only curr = curr + numbers[i]; thereby doing some kind of partial sort? I have no idea how this can be done.
The class MaxSum is boilerplate which doesn't contribute to the solution. Including it forces a programmer to read and understand code that doesn't do anything. Just declare MaxSum::findMaxSum at namespace scope.
If you simply want "MaxSum" to serve as a grouping of names, use a namespace instead.