Split an array into minimum number of non-increasing or non-decreasing subarrays
Given an array arr[] of size N, the task is to split the given array into a minimum number of subarrays such that elements of each subarray are either in non-increasing order or non-decreasing order. Examples: Input: arr[] = {2, 3, 9, 5, 4, 6, 8}Output: 3Explanation: Split the array into 3 subarrays