Kadanes Algorithms problem

Hi Sir, In this problem we can get maximum sum in O(n) but if we need to know the subarray from which we get this maximum sum then what should we do?

Hi, to get the array store the starting index and last index of the array which is currently maximum, in case you find a new larger sum, update your current maximum starting and last index.