2.Maximum Product Subarray
Solution: (Dynamic Programing)
Algorithm: Keep a track of 2 variables: -> maxEnding and minEnding * For all the elements calculate the maxEnding and MinEnding * If an element is negative swap maxEnding and MinEnding
Time Complexity: O(n)
Last updated
Was this helpful?