Skip to content

Commit b61246a

Browse files
authored
Create 3396. Minimum Number of Operations to Make Elements in Array Distinct
1 parent b9672d2 commit b61246a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
int minimumOperations(vector<int>& v) {
4+
int n=v.size();
5+
unordered_map<int,int>frq;
6+
for(int i=n-1;i>=0;--i){
7+
if(frq[v[i]]){
8+
return ((i+3)/3);
9+
}
10+
frq[v[i]]++;
11+
}
12+
return 0;
13+
}
14+
};

0 commit comments

Comments
 (0)