Optimizing Maximum Subarray Sum Algorithm for LeetCode-53

The code solves a problem finding maximum subarray sum in an array. What i have done here solve the problem properly. But here the new problem is the code is not optimized. It becomes huge when the input is big. Here, Time Complexity = O(n²) Space Complexity = O(1)/constant It gets time limit exceeded when the input is big. So when we run this code on a server, it demand a huge CPU power and increases cost and decreases efficiency. This shows the need of optimal solution. That's we need to learn how to write code optimally. There's an algorithm that solves this problem optimally. Can you guess that? If you can, comment below. This problem is from Leetcode-53. #programming #leetcode #coding

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories