From 427208c9749bbf9d257b2b523acd1fdf420038b3 Mon Sep 17 00:00:00 2001 From: Parth Saini <56781801+parthsaini08@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:07:25 +0530 Subject: [PATCH] Add files via upload --- Leetocode 1338 solution.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Leetocode 1338 solution.cpp 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