Company: Deshaw full time_15march
Difficulty: medium
You are given an array of integers arr[] of length n . In one operation you may: Pick any element and move it to the end of the array, leaving the relative order of the other elements unchanged. Your goal is to reach a state where every group of equal elements sits together, using as few operations as possible. Note: Grouping succeeds once, for every value x in the array, all occurrences of x form one contiguous block. Example n = 5 arr = [1, 2, 2, 1, 3] Here the array is [1, 2, 2, 1, 3]. One way to group equal elements is: Move the element at position 4 to the end → [1, 2, 2, 3, 1] Move the element at position 1 to the end → [2, 2, 3, 1, 1] Now every 1, 2, and 3 sits in its own contiguous block. So the answer is 2. Function Description Complete the function getMinOperations in the editor below. getMinOperations has the following parameter: int arr[n] : the elements of the array arr . Returns int : an integer giving the minimum number of operations needed. Constraints 1 ≤