You are viewing a single comment's thread. Return to all comments →
Here is my O(N) c++ solution, you can watch the explanation here : https://youtu.be/8p9yuqSv4ek
int equalizeArray(vector<int> arr) { map<int, int>mp; int mx = 0; for(int el: arr) { mp[el]++; if(mp[el]>mx) mx = mp[el]; } return arr.size() - mx; }
Seems like cookies are disabled on this browser, please enable them to open this website
Equalize the Array
You are viewing a single comment's thread. Return to all comments →
Here is my O(N) c++ solution, you can watch the explanation here : https://youtu.be/8p9yuqSv4ek