TypeScript, simple solution | Runtime beats 100%, Memory beats 64.29%
Intuition\n To split the array into the maximum number of chunks, each chunk should be sorted individually and then concatenated to form a fully sorted array.\n
# Intuition\n To split the array into the maximum number of chunks, each chunk should be sorted individually and then concatenated to form a fully sorted array.\n\n# Approach\nTrack Extremes: Record maximum values up to each index and minimum values from each index.\n\nCount Valid Chunks: Count positions where the maximum value to the left is \u2264 minimum value to the right.\n\n# Complexity\n- Time complexity:\nO(n) \u2014 Single pass for maxLeft and minRight, and another for counting.\n\n- Space complexity:\nO(n) \u2014 Arrays to store extremes.\n\n# Code\n```typescript []\nfunction maxChunksToSorted(arr: number[]): number {\n    const n = arr.length;\n    const maxLeft: number[] = new Array(n);\n    const minRight: number[] = new Array(n);\n    \n    maxLeft[0] = arr[0];\n    for (let i = 1; i < n; i++) {\n        maxLeft[i] = Math.max(maxLeft[i - 1], arr[i]);\n    }\n    \n    minRight[n - 1] = arr[n - 1];\n    for (let i = n - 2; i >= 0; i--) {\n        minRight[i] = Math.min(minRight[i + 1], arr[i]);\n    }\n    \n    let chunks = 0;\n    for (let i = 0; i < n - 1; i++) {\n        if (maxLeft[i] <= minRight[i + 1]) {\n            chunks++;\n        }\n    }\n    \n    return chunks + 1; // Include the last chunk\n}\n\n```
['TypeScript']