Minimize length of an array by repeatedly removing elements that are smaller than the next element
Given an array arr[] consisting of N integers, the task is to repeatedly remove elements that are smaller than the next element. Examples: Input: arr[] = {20, 10, 25, 30, 40}Output: 40Explanation:Below are the operations that are performed: Current array: arr[] = {20, 10, 25, 30, 40} Currently, arr[