Descritpion:-
I create a vector nums and try to store their sum upto their index and then print out maximum .
All public test cases are passed and also one hidden test case but I got runtime error(sigabrt)
My solution link:-
Descritpion:-
I create a vector nums and try to store their sum upto their index and then print out maximum .
All public test cases are passed and also one hidden test case but I got runtime error(sigabrt)
My solution link:-
There are basically two errors in your solution.
vector<int>nums={(x+arr[0])}
. This only declares a vector of size 1. Declare it something like this.vector<int>nums(n); nums[0] = x+arr[0];
x = 100 and arr[0] = -2.
int maxi= max(x, nums[0]);
Thank you!
we can use Kadanes algorithm