C++ using nth_element
\nclass Solution {\npublic:\n    int findMedian(vector<int> a, int n)  \n      {    \n         \n     if (n % 2 == 0) \n          { \n            nth_element( a
```\nclass Solution {\npublic:\n    int findMedian(vector<int> a, int n)  \n      {    \n         \n     if (n % 2 == 0) \n          { \n            nth_element( a.begin() , a.begin() + (n-1)/2 , a.end() );\n \n            return ( a[(n - 1) / 2] );    \n          }\n         else\n         {  \n            // Applying nth_element on n/2\n            nth_element( a.begin() , a.begin() + n/2 ,a.end() );\n\n            return a[n / 2]; \n         }\n     \n} \n    vector<int> getStrongest(vector<int>& arr, int k) {\n        int m=findMedian(arr,arr.size());\n\n         vector<pair<int, int>>V;\n        for(int i:arr)\n        {  \n             V.push_back(make_pair(i,abs(i-m)));\n           \n        }\n       sort(V.begin(),V.end(),[](pair<int,int> a,pair<int,int> b){\n           if(a.second==b.second) return a.first > b.first;\n            else return a.second>b.second;\n    });\n       \n        \n        vector<int>V1;\n        for(auto it : V)\n        {    \n             V1.push_back(it.first);\n             k--;\n            if(k==0) break;\n        }\n        return V1;\n    }\n};\n```
[]