Video Explanation (Includes 2 Harder follow-ups - subsequence & k-arrays instead of 2)
Explanation\n\nClick here for the video link\n\n# Code\n\nclass Solution {\n    vector<vector<int>> nums;\n    vector<vector<int>> dp;\n    int n;\n    \n    in
# Explanation\n\n[Click here for the video link](https://youtu.be/R3YJP_gxZqc)\n\n# Code\n```\nclass Solution {\n    vector<vector<int>> nums;\n    vector<vector<int>> dp;\n    int n;\n    \n    int MaxDecreasingLength (int prv_num, int ind) {\n        if (ind == n) return 0;\n        \n        int &ans = dp[prv_num][ind];\n        if (ans != -1) return ans;\n        \n        ans = 0;\n        for (int j = 0; j < nums.size(); j ++) {\n            if (nums[prv_num][ind-1] <= nums[j][ind])\n                ans = max (ans, 1 + MaxDecreasingLength (j, ind+1));\n        }\n        \n        return ans;    \n    }\n    \npublic:\n    int maxNonDecreasingLength(vector<int>& nums1, vector<int>& nums2) {\n        dp.clear();\n        nums = {nums1, nums2};\n        n = nums1.size();\n        \n        dp.resize(2, vector<int>(n, -1));\n        \n        int ans = 1;\n        for (int j = 0; j < n-1; j ++) {\n            ans = max (ans, 1+MaxDecreasingLength(0, j+1));\n            ans = max (ans, 1+MaxDecreasingLength(1, j+1));\n        }\n        return ans;\n    }\n};\n```
['C++']