tungggg

equalizeArray Hackerrank

Mar 12th, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. int equalizeArray(vector<int> arr) {
  2.     map<int, int > mp ;
  3.     for (int i=0 ;i<arr.size();i++){
  4.         mp[arr[i]]++ ;
  5.     }
  6.     int maxVal=-1 ;
  7.     for (auto x: mp){
  8.         if ( x.second >maxVal ){
  9.             maxVal = x.second ;
  10.         }
  11.     }
  12.     return arr.size()  - maxVal ;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment