+ minimum number of operations to make array distinct + — 9/13/24 +
+understanding the problem
++ You can remove elements in groups of 3 solely from the + beginning of the array. Perform this operation until there are no + more duplicates left, returning the number of times you had to + perform the operation. +
+solution: rephrase the question
+
+ Definitionally, you remove the last duplicate. If such
+ duplicate is at 0-indexed i, it belongs to the \(\lceil
+ \frac{i + 1}{3}\rceil\)th chunk of 3 (i.e. operation). Find the last
+ duplicate by leveraging a frequency map and iterating backwards
+ through the input.
+
asymptotic complexity
++ The solution is optimal, considering the least amount of elements + possible in: +
+-
+
- Time Complexity: \(\O(n)\) +
- Space Complexity: \(\Theta(1)\) +