MaxSubArraySum-Kadane-s-algorithm Time Complexity: O(n), where n is the number of elements in the input array. The algorithm only makes one pass through the array. Space Complexity: O(1), since only a constant amount of extra space is used for the variables res and maxsum.