diff --git a/Leetocode 1338 solution.cpp b/Leetocode 1338 solution.cpp new file mode 100644 index 00000000..80654338 --- /dev/null +++ b/Leetocode 1338 solution.cpp @@ -0,0 +1,21 @@ +class Solution { +public: + int minSetSize(vector& arr) { + vector> ans; + unordered_map m; + for(auto x:arr) + m[x]++; + for(auto x:m) + ans.push_back({x.second,x.first}); + sort(ans.begin(),ans.end(),greater>()); + int fans=0,temp=0,n=arr.size()/2; + for(int i=0;i=n) + return fans; + } + return 0; + } +}; \ No newline at end of file