left_max and right_min, of the same length as the input array arr.left_max[0] to arr[0] and iterate through arr from left to right, populating left_max such that left_max[i] is the maximum value from arr[0] to arr[i].right_min[arr.length - 1] to arr[arr.length - 1] and iterate through arr from right to left, populating right_min such that right_min[i] is the minimum value from arr[i] to arr[arr.length - 1].count to 0 to keep track of the number of chunks.arr.length - 2 and increment count each time left_max[i] is less than or equal to right_min[i + 1].count by 1 to account for the last chunk.count as the maximum number of chunks.