1D Dynamic Problems

  1. Decode Ways:
  1. Max Product Subarray
    maxProduct(nums) {
    
    

let res = nums[0];

let curMax = 1;

let curMin = 1;

for(let n of nums){

let tmp = curMax * n;

curMax = Math.max(n, curMaxn, curMinn);

curMin = Math.min(n, tmp, curMin*n);

res = Math.max(res, curMax);

}
        return res;
    }


11. Longest Increasing SubSequence
      - great problem!
      - link - https://neetcode.io/problems/longest-increasing-subsequence?list=neetcode150
      ```js
       lengthOfLIS(nums) {

        let cache = new Array(nums.length).fill(1);

        for(let i = nums.length-1; i >=0; i--){

            for(let j =i+1; j  < nums.length; j++){

                if(nums[i]<nums[j])

                cache[i] = Math.max(cache[i], 1+ cache[j]);

            }

        }

  

        return Math.max(...cache);

    }
  1. Partition Equals Subset Sum