https://hack.codingblocks.com/contests/c/474/1259
https://ide.codingblocks.com/#/s/25222
Maximum Subarray Sum hb
https://ide.codingblocks.com/#/s/25719
This is the corrected code.
Your approach was correct.
Please see the constraints of question carefully.
The size of array had to be taken 100000 as mentioned in the question.