46 - Maximum Product Subarray - Dynamic Programming approach 1

@Rishi Srivastava Pseudo code: int currMax = 1; int currMin = 1; for (int num : nums[]) { int tmp = currMax * num; currMax = MAX(num * currMax, num * currMin, num); // currMax is changed here currMin = MIN(tmp, num * currMin, num); result = MAX(result, currMax); } Github: Leetcode: - Dynamic Programming Playlist: - Dynamic Programming Github: - Java Serialization Playlist: - Java Serialization Github: #java #java
Back to Top