Maximum subarray sum(hackers block)

i am not able to code according to the qustion

https://ide.codingblocks.com/s/104379 - this is the url of my code

https://hack.codingblocks.com/contests/c/917/1259 - and this is the url of the question in case

@Ayushi21
Since the constraints mentioned in the question are large , we need to solve it using an optimised method. You are using an O(n²) method .
Try using Kadane’s Algorithm. It is used to calculate maximum subarray sum in O(n) time and would be suitable for this question. It is covered in the tutorial videos. Kindly refer to it and try coding using Kadane’s Algo

Note : Make sure you are using long long int as you can see the array values can be as large as 10^9. Since the values are so large , their sum is bound to exceed the range of int. So use long long int to store the currentSum and maxSum in Kadane’s Algo.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.