Company: Probo_4july
Difficulty: medium
Minimum Operations to Sort Array Problem Description You are given an array a of n positive integers a 1 , a 2 , ..., a n . In one operation you do the following: Choose any integer x. For every index i whose current value a i is equal to x, set a i = 0. Each operation is counted, whatever x you choose and whether or not any value actually changes. Operations are applied one after another, and an operation looks at the values the array holds at that moment. Find the minimum number of operations after which the array is sorted in non-decreasing order, that is, a 1 <= a 2 <= ... <= a n . Input Format The first line contains a single integer n, the length of the array. The second line contains n space-separated integers a 1 , a 2 , ..., a n . Output Format Print one integer: the minimum number of operations required to make the array non-decreasing. If the array is already non-decreasing, print 0 . Examples Example 1: Input: 3 3 3 2 Output: 1 Explanation: Choose x = 3. Both entri