Javascript dp
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfunction nonDecreasing(elements) {\n    function getMaximumIncreasingSequence(elementsCopy) {\n        let sequence = []\n        for (let i = 0; i < elementsCopy.length; i++) {\n            const current = elementsCopy[i]\n            const currentMaximum = +sequence[sequence.length-1] || 0\n            if (current >= currentMaximum) {\n                sequence.push(current)\n            } else {\n                let j = 0;\n                while (current >= sequence[j]) {\n                    j++;\n                }\n                sequence[j] = current;\n            }\n        }\n        \n\n        // console.log(\'dp\', dp)\n\n        return sequence.length\n    }\n\n    const increasingSequence = getMaximumIncreasingSequence(elements)\n\n    return elements.length - increasingSequence\n}\n\nfunction kIncreasing(arr, k = 0) {\n    const subsequencesLength = Math.ceil(arr.length / k)\n    let subsequences = []\n\n    if (k === 1) subsequences.push(arr)\n    else {\n        for (let i = 0; i < k; i++) {\n            subsequences[i] = []\n            for (let j = 0; j < subsequencesLength; j++) {\n                const index = i + k * j\n                if (index in arr) subsequences[i].push(arr[index])\n            }\n        }\n    }\n\n    return subsequences.map(nonDecreasing).reduce((a, e) => a + e)\n}\n```
['JavaScript']