id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n\n vector<int> indexes(n);\n iota(indexes.begin(), indexes.end(), 0);\n sort(indexes.begin(), indexes.end(), [&](int& i, int& j) {\n return...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n for(int i=0;i<heights.size()-1;i++){\n for(int j=i+1;j<heights.size();j++){\n if(heights[j]>heights[i]){\n swap(names[i],names[j]);\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n int partition(vector<string>& names, vector<int>& heights, int low, int high){\n int pivot = heights[low];\n int i = low, j = high;\n\n while(i < j){\n\n while(i <= high && heights[i] >= pivot){\n i++;\n }\n\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\n public:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> result(names.size());\n vector<int> index(names.size());\n iota(index.begin(), index.end(), 0);\n sort(index.begin(), index.end(), [&heights](int i, int j...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = heights.size();\n\n for(int i=0;i<=n-1;i++){\n int max=i;\n for(int j= i;j<=n-1;j++){\n if(heights[max]<=heights[j]){\n max...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> ans(names.size());\n vector<int> a(names.size());\n iota(a.begin(), a.end(), 0);\n sort(a.begin(), a.end(), [&](const int &h1, const int&h2){\n ret...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n std::vector<size_t> indexes(heights.size());\n std::iota(indexes.begin(), indexes.end(), 0);\n std::sort(indexes.begin(), indexes.end(), [&heights](const auto &a, const auto &b) {\...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& h) {\n std::priority_queue<std::pair<int, int>> q;\n int i;\n for (i = 0; i < h.size(); ++i)\n q.push({h[i], i});\n vector<string> ret(names.size());\n i = 0;\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n Solution() {\n std::ios::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n }\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n std::vector<size_t> indexes(heights.size());\n std::io...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\n public:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<int> s_heights = heights;\n sort(s_heights.begin(), s_heights.end(), greater<int>());\n vector<string> s_names = names;\n set<int> s;\n for (int i=0; i<hei...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n pair <int,string> p[heights.size()];\n for(int i=0;i<heights.size();i++)\n {\n p[i].first=heights[i];\n p[i].second=names[i];\n }\n sort(p,p+hei...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n pair <int,string> p[heights.size()];\n for(int i=0;i<heights.size();i++)\n {\n p[i].first=heights[i];\n p[i].second=names[i];\n }\n sort(p,p+hei...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n for(int i=0;i<heights.size()-1;i++){\n int maxIndex=i;\n for(int j=i+1;j<heights.size();j++) {\n if(heights[j]> heights[maxIndex]) {\n maxIndex= j;\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string>result;\n for(int i=0;i<names.size();i++)\n {\n int maxHeight =INT_MIN;\n for(int j:heights)\n {\n maxHeight=ma...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution\n{\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights)\n {\n vector<string> result;\n for(int i = 0; i < names.size(); i++)\n {\n int maxHeight = INT_MIN;\n for(int j : heights)\n {\n max...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n \n vector<string>result;\n for(int i=0;i<names.size();i++)\n {\n int maxHeight =INT_MIN;\n for(int j:heights)\n {\n maxHeight=ma...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution\n {\n public:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights)\n {\n vector<string>result;\n for(int i=0;i<names.size();i++)\n {\n int maxHeight =INT_MIN;\n for(int j:heights)\n {\n ma...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=heights.size();\n vector<string> ans;\n int cnt=0;\n while(cnt<n){\n int idx=0;\n int maxVal=*max_element(heights.begin() , heights.end());\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int temp = 0;\n string n;\n for (int i = 0; i < heights.size() - 1; i++) {\n for (int j = i + 1; j < heights.size(); j++) {\n if (heights[i] < heights[j])...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n vector<string> ans(n);\n vector<pair<int, string>> v(n);\n for (int i = 0; i < n; i++) {\n v[i] = make_pair(heights[i], names[i]);\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=names.size(),i;\n vector<pair<int, string>> vp(n);\n for(i=0;i<n;i++){\n vp[i] = {heights[i], names[i]};\n }\n sort(vp.begin(),vp.end());\n ve...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = heights.size();\n for(int i = 1; i<n; i++){\n int key = heights[i];\n string name = names[i];\n int j = i-1;\n while(j>=0 && heights[j]...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=names.size();\n vector<pair<int,string>> ans(n);\n for(int i=0;i<names.size();i++){\n ans[i]={heights[i],names[i]};\n }\n sort(ans.begin(),ans.end(),...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=heights.size();\n vector<pair<int,string>> h(n);\n for(int i=0;i<n;i++){\n h[i]={heights[i],names[i]};\n }\n sort(h.begin(),h.end(), greater<>());\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int,int>> h;\n int c=0;\n int n=heights.size();\n for(int i=0;i<n;i++){\n h.push_back({heights[i],c});\n c++;\n }\n sort(h.begin(),h.end(),greate...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n\n void swap(int& a, int& b, string& s1, string& s2){\n int temp = a;\n a = b;\n b = temp;\n\n string temp1 = s1;\n s1 = s2;\n s2 = temp1;\n \n }\n int partition(vector<string>& names, vector<int>& heights, int s, int e){\...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n template<class T> // powerful syntax\n void swap(vector<T>& arr, int i, int j){\n T temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n void sort(vector<int>& heights, vector<string>& names, int left, int right){\n int l = left, r =...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Person {\npublic:\n string name;\n int height;\n Person(string name, int height) : name(name), height(height) {};\n};\n\nusing vp = vector<Person>;\nusing vs = vector<string>;\n\nclass Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n template<class T> // powerful syntax\n void swap(vector<T>& arr, int i, int j){\n T temp = arr[i];\n arr[i] = arr[j];\n arr[j] = temp;\n }\n void sort(vector<int>& heights, vector<string>& names, int left, int right){\n int l = left, r =...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights){\n vector<string>ans(names.size());\n int arr[names.size()];\n int count;\n for(int i=0;i<heights.size();i++)\n { count=0;\n for(int j=0;j<heights.size();j++)...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n std::vector<std::pair<std::string, int>> people;\n for (size_t i = 0; i < names.size(); ++i) {\n people.emplace_back(std::move(names[i]), heights[i]);\n }\n \n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int number_of_people = names.size();\n\n // Create a map to store height-name pairs\n unordered_map<int, string> height_to_name_map;\n\n // Populate the map with height as k...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n vector<pair<int,string>> peoples(n);\n\n for(int i=0; i<n; i++){\n peoples[i] = {heights[i], names[i]};\n }\n\n sort(peoples.begin(...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n int n=names.size();\n vector<string> result(n);\n unordered_map<int ,string > mp;\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
0
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n unordered_map<int, int>mp;\n for(int i=0; i<heights.size(); i++)\n mp[heights[i]] = i;\n sort(heights.begin(), heights.end(), greater<int>());\n vector<string>ans...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int, int, greater<int>> sortedHeights;\n\n for (int i = 0; i < heights.size(); ++i) {\n sortedHeights[heights[i]] = i;\n }\n\n vector<string> result;\n for (const auto& ent...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n unordered_map<int,string> mp;\n for (int i = 0; i<n; i++){\n mp[heights[i]] = names[i];\n }\n sort(heights.begin(),heights.end(),gr...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<Person *> vp;\n int n = names.size();\n for(int i = 0; i < n; i++)\n vp.push_back(new Person(names[i], heights[i]));\n sort(vp.begin(), vp.end(), [&](Perso...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int, string> people{};\n for (int i = 0; i < heights.size(); i++) {\n people[heights[i]] = names[i];\n }\n vector<string> sortedNames{names.size()};\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int,string>>temporary(0);\n for(int i=0;i<heights.size();i++)\n {\n temporary.push_back(make_pair(heights[i],names[i]));\n }\n sort(temporary.b...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n quickSort(heights, names, 0, heights.size() - 1);\n return names;\n }\n\nprivate:\n void swap(vector<int>& heights, vector<string>& names, int index1,\n int index2) {\n...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n set<pair<int, string>> s;\n int n = names.size();\n for (int i = 0; i < n; ++i) {\n s.insert({-heights[i], names[i]});\n }\n for (int i = 0; i < n; ++i) {\...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int h=heights.size()-1;\n map<int, string> mp;\n for(int i=0;i<names.size();i++) {\n mp[heights[i]] = names[i];\n }\n sort(heights.begin(),heights.end());\n for(i...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> ans(heights.size());\n map<int, string> m;\n for(int i=0;i<heights.size();i++){\n m[-1*heights[i]]=names[i];\n }\n // for(auto it:m){\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> ans;\n unordered_map<int, string> mp; \n for(int i=0; i<names.size(); i++){\n mp[heights[i]] = names[i];\n }\n sort(heights.begin(), heights...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int,string>Map;\n for(int i=0;i<names.size();i++) \n {\n Map[heights[i]]=names[i];\n } \n vector<string>res(names.size(),\"\");\n int i=names.size()-1;\n for(...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n static bool comparePairs(pair<string, int>&pair1, pair<string, int>&pair2)\n {\n return pair1.second>pair2.second;\n }\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) \n {\n vector<pair<string, int>>vec1;\n for(int i=0...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n static bool custm(pair<string,int>& a,pair<string,int>& b)\n {\n return a.second>b.second;\n }\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<string,int> >helper;\n for(int i=0;i<names.size();i++)\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int,string>> p;\n for(int i=0;i<names.size();i++){\n p.push_back({heights[i],names[i]});\n }\n sort(p.begin(),p.end());\n vector<string> ans;\n...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
1
{ "code": "class Solution {\nprivate:\n static bool second(const pair<string,int> &a,const pair<string,int> &b)\n {\n return a.second>b.second; \n } \npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<string,int>>Vec;\n for(int i=0;i...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<string,int>> vp;\n for(int i=0;i<names.size();i++) vp.push_back({names[i],heights[i]});\n sort(vp.begin(),vp.end(),[&](pair<string,int> &a,pair<string,int> &b){\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int,string> mp;\n int n=names.size();\n for(int i=0;i<n;i++)\n mp[heights[i]]=names[i];\n sort(heights.begin(),heights.end(),greater<int> ());\n vector<string> str;\n for(...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int, string> mp;\n vector<string> result;\n int size = names.size();\n\n for(int i = 0; i < size; i++) {\n mp[heights[i]] = names[i];\n }\n\n fo...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int, string>mp;\n for(int i=0;i<names.size();i++){\n mp[heights[i]] = names[i];\n }\n vector<string>ans;\n for(auto i=mp.rbegin();i!=mp.rend();i++){\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int,string> mp;\n for(int i=0;i<names.size();++i)\n {\n mp[heights[i]]=names[i];\n }\n vector<string> ans;\n for(auto i:mp)\n {\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int,string>m;\n for(int i=0;i<heights.size();i++){\n m[heights[i]]=names[i];\n }\n vector<string>result;\n for(auto x:m){\n result.push_back...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int,string,greater<int>> mpp;\n for(int i=0;i<names.size();i++){\n mpp.insert(pair<int,string>(heights[i],names[i]));\n }\n vector<string> ans;\n for(a...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n \n int n =names.size();\n map< int , string > mp;\n\n for(int i =0 ; i< n ;i++){\n mp[heights[i]] = names[i];\n\n }\n\n sort(heights.begin()...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n //store in priority queue(height:name)\n priority_queue<pair<int,string>>pq;\n for(int i = 0; i<names.size();i++)\n {\n pq.push({heights[i],names[i]});\n }...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) \n {\n priority_queue<pair<int,string>>pq;\n for(int i=0;i<names.size();i++)\n {\n pq.push({heights[i],names[i]});\n }\n \n vector<string>ans;\n\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
2
{ "code": "class Solution\n {\n public:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights)\n {\n map<int,string,greater<int>> mapping;\n vector<string>ans;\n int n=names.size();\n for(int i=0;i<n;i++)\n {\n mapping[heights[i]]=names[...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n unordered_map<int, string> mp;\n for(int i = 0; i < n; i++){\n mp[heights[i]] = names[i];\n }\n sort(heights.rbegin(), heights.rend...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n unordered_map<int, string> mapping;\n for(int i = 0;i < n; i++)\n {\n mapping[heights[i]] = names[i];\n }\n\n sort(heights....
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=names.size();\n unordered_map<int,string>mapping;\n\n for(int i=0;i<n;i++){\n mapping[heights[i]]=names[i];\n }\n\n\n sort(heights.rbegin()...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "#pragma GCC optimize(\"O3\")\n#pragma GCC target(\"avx2\")\nclass Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n unordered_map<int,string>m;\n for(int i=0;i<names.size();++i){\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int, string>> nameHeight;\n for(int i=0;i<names.size();i++){\n nameHeight.push_back({heights[i], names[i]});\n }\n sort(nameHeight.rbegin(), nameHeigh...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int, string>> arr;\n for (int i = 0; i < names.size(); i++) {\n arr.push_back({heights[i], names[i]});\n }\n sort(rbegin(arr), rend(arr));\n fo...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = heights.size();\n vector<pair<int, string>> indices;\n for (int i = 0; i < n; ++i){\n indices.push_back({heights[i], names[i]});\n }\n\n sort(indic...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> peoples;\n vector<pair<int,string>> pr;\n for(int i=0; i<names.size(); i++){\n pr.push_back(make_pair(heights[i],names[i]));\n }\n priority_...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=names.size();\n map<int,string>mp;\n for(int i=0;i<n;i++)\n {\n mp[heights[i]]=names[i];\n } \n sort(heights.rbegin(),heights.rend());\n for(int i=0;i<n;i++)\n...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int,string> mp;\n\n for(int i=0;i< heights.size();i++){\n mp[heights[i]] = names[i];\n }\n sort(heights.rbegin(), heights.rend());\n\n for(int i=0;i< heights.size();i++){\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n if(heights.size() == 0){\n return names;\n }\n int s = 0;\n int e = heights.size()-1;\n mergeSort(names, heights, s , e);\n for(int i=0; i<heights.s...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=names.size();\n //lets do it its easy\n unordered_map<int,string> map;\n vector<string> ans;\n //lets store this in the map first and then we will sort it acc t...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=names.size();\n //lets do it its easy\n unordered_map<int,string> map;\n vector<string> ans;\n //lets store this in the map first and then we will sort it acc t...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n vector<pair<int,string>> v;\n for(int i = 0; i < n; i++){\n v.push_back({heights[i], names[i]});\n }\n sort(v.rbegin(),v.rend());\n...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int, string>> pair;\n for (int i = 0; i < names.size(); i++) {\n pair.push_back({heights[i], names[i]});\n }\n sort(pair.rbegin(), pair.rend());\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& n, vector<int>& h) {\n vector<pair<int, string>> v; \n for (int i = 0; i < n.size(); i++) {\n v.push_back({h[i], n[i]});\n }\n sort(v.rbegin(), v.rend());\n vector<string> ans;\n f...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int, string>> heightNamePairs; \n for (int i = 0; i < names.size(); i++) { \n heightNamePairs.emplace_back(heights[i], names[i]); \n } \n sort(hei...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n \n vector<pair<int,string>> temp;\n\n for(int i=0;i<names.size();i++)\n temp.push_back({heights[i],names[i]});\n \n vector<string> ans;\n sort(temp....
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> ans;\n vector<pair<int, string>> temp;\n int n = names.size();\n for (int i = 0; i < n; i++) {\n temp.push_back({heights[i], names[i]});\n }...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> ans;\n vector<pair<int, string>> temp;\n int n = names.size();\n for (int i = 0; i < n; i++) {\n temp.push_back({heights[i], names[i]});\n }...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n vector<pair<int,string>> temp;\n for(int i=0;i<names.size();i++){\n temp.push_back({heights[i],name...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n std::vector<std::string> sortPeople(std::vector<std::string>& names, std::vector<int>& heights) {\n mergeSort(names, heights);\n return names;\n }\n\nprivate:\n void mergeSort(std::vector<std::string>& names, std::vector<int>& heights) {\n\n if (nam...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int,string>> pairs;\n int n = names.size();\n for (int i = 0; i < n; i++){\n string name = names[i];\n int height = heights[i];\n pairs...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int,string>> combo;\n for(int i = 0; i < names.size(); i++){\n pair temp(heights[i], names[i]);\n combo.push_back(temp);\n }\n sort(combo.r...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int,int>> vp;\n for(int i=0;i<names.size();i++) {\n vp.push_back({heights[i], i+1});\n }\n sort(vp.rbegin(), vp.rend());\n map<int,string> mp;\...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n=names.size();\n vector<pair<int,string>> v(n);\n for(int i=0;i<n;i++){\n v.push_back({heights[i],names[i]});\n }\n sort(v.begin(),v.end());\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n map<int, int> index;\n map<int , string> namess; \n for(int i=0; i<heights.size(); i++){\n namess[heights[i]] = names[i];\n index[heights[i]] = i;\n }\...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) \n {\n vector<pair<int,string>>mp;\n vector<string>ans;\n priority_queue<pair<int,string>>q;\n for(int i=0;i<heights.size();i++)\n {\n mp.push_back({heights...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) \n {\n vector<pair<int,string>>mp;\n vector<string>ans;\n priority_queue<pair<int,string>>q;\n for(int i=0;i<heights.size();i++)\n {\n mp.push_back({heights...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n // Merge sort in C++\n\n\n void mergeM(vector<string>& names, vector<int>& arr, int p, int q, int r) {\n \n // Create L ← A[p..q] and M ← A[q+1..r]\n int n1 = q - p + 1;\n int n2 = r - q;\n\n int L1[n1], M1[n2];\n string L2[n1], M2[n2];\n\n for (int i ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\n void merge(vector<string>& names, vector<int>& heights, int l, int r, int m){\n int n1 = m-l+1;\n int n2 = r-m;\n int v1[n1], v2[n2];\n string names1[n1], names2[n2];\n for(int i=l;i<=m;i++){\n v1[i-l] = heights[i];\n names1[i-l...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> ans;\n vector<vector<int>> v;\n\n for( int i = 0; i < names.size(); i++ ){\n vector<int> temp;\n temp.push_back(heights[i]);\n temp....
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> ans;\n vector<vector<int>> v;\n\n for( int i = 0; i < names.size(); i++ ){\n vector<int> temp;\n temp.push_back(heights[i]);\n temp....
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n std::unordered_map<std::string,int> names_heights;\n std::unordered_map<int,std::string> heights_names;\n for (int i = 0; i < n; i++) {\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n int n = names.size();\n std::unordered_map<std::string,int> names_heights;\n std::unordered_map<int,std::string> heights_names;\n for (int i = 0; i < n; i++) {\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string>ans;\n map<int,vector<string>>mp;\n int n=names.size();\n for(int i=0;i<n;i++)\n {\n mp[heights[i]].push_back(names[i]);\n }\n ...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> ans;\n multimap<string,int> mp;\n int n = names.size();\n for(int i=0;i<n;++i){\n mp.insert({names[i],heights[i]});\n }\n \n p...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "class Solution {\npublic:\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<string> res;\n int n=names.size();\n map<int,string> mp;\n for(int i=0;i<n;i++){\n mp[heights[i]]=names[i];\n }\n vector<pair<int,string>> ve...
2,502
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p> <p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <c...
3
{ "code": "\nbool compareFunc(pair<int, string> &p1, pair<int, string> p2) {\n return p1.first > p2.first;\n}\n\nclass Solution {\npublic:\n\n vector<string> sortPeople(vector<string>& names, vector<int>& heights) {\n vector<pair<int, string>> V;\n vector<string> result;\n int n = names.siz...