id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
2,176 | <p>You are given an integer <code>n</code>, which indicates that there are <code>n</code> courses labeled from <code>1</code> to <code>n</code>. You are also given a 2D integer array <code>relations</code> where <code>relations[j] = [prevCourse<sub>j</sub>, nextCourse<sub>j</sub>]</code> denotes that course <code>prevC... | 3 | {
"code": "class Solution {\npublic:\n int dp[50003];\n unordered_map<int,vector<int>>tree;\n vector<int> t;\n\n\n int solve(int node){\n if (dp[node]!=-1) return dp[node];\n int ans = 0;\n for (auto x : tree[node]){\n ans = max(ans,solve(x));\n }\n dp[node]=a... |
2,176 | <p>You are given an integer <code>n</code>, which indicates that there are <code>n</code> courses labeled from <code>1</code> to <code>n</code>. You are also given a 2D integer array <code>relations</code> where <code>relations[j] = [prevCourse<sub>j</sub>, nextCourse<sub>j</sub>]</code> denotes that course <code>prevC... | 3 | {
"code": "class Solution {\npublic:\n int dp[50003];\n unordered_map<int,vector<int>>tree;\n vector<int> t;\n\n\n int solve(int node){\n if (dp[node]!=-1) return dp[node];\n int ans = 0;\n for (auto x : tree[node]){\n ans = max(ans,solve(x));\n }\n dp[node]=a... |
2,176 | <p>You are given an integer <code>n</code>, which indicates that there are <code>n</code> courses labeled from <code>1</code> to <code>n</code>. You are also given a 2D integer array <code>relations</code> where <code>relations[j] = [prevCourse<sub>j</sub>, nextCourse<sub>j</sub>]</code> denotes that course <code>prevC... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<int,list<int> > adj;\n int minimumTime(int n, vector<vector<int>>& relations, vector<int>& time) {\n // unordered_map<int,int > mp;\n vector<int> inDegree(n,0);\n\n for(auto course : relations){\n adj[course[0]-1].push_back(cou... |
2,176 | <p>You are given an integer <code>n</code>, which indicates that there are <code>n</code> courses labeled from <code>1</code> to <code>n</code>. You are also given a 2D integer array <code>relations</code> where <code>relations[j] = [prevCourse<sub>j</sub>, nextCourse<sub>j</sub>]</code> denotes that course <code>prevC... | 3 | {
"code": "class Solution {\n int calculateCost(int course, unordered_map<int, vector<int>> & adjList, vector<int> & time, vector<int> & cost) {\n int currCost = time[course-1];\n cost[course] = time[course-1];\n for(auto depCourse: adjList[course]) {\n if(cost[depCourse] == -1) {\n... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "static const int __ = [](){\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n return 0;\n}();\n\nint init = [] {\n ofstream out(\"user.out\");\n cout.rdbuf(out.rdbuf());\n for (string str, k_str; getline(cin, str) && getline(cin, k_str); cout << '\\n') {\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "static const int __ = [](){\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n return 0;\n}();\n\nint init = [] {\n ofstream out(\"user.out\");\n cout.rdbuf(out.rdbuf());\n for (string str, k_str; getline(cin, str) && getline(cin, k_str); cout << '\\n') {\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int unq = 0;\n if (k > arr.size())\n return \"\";\n for (int i = 0; i < arr.size(); i++) {\n int cnt = 0;\n for (int j = 0; j < arr.size(); j++) {\n if (arr... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int n = arr.size();\n for(int i=0;i<n;i++){\n string curr = arr[i];\n bool distinct = true;\n for(int j=0;j<n;j++){\n if(i == j){\n continue;\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int distinctCount = 0;\n for (int i = 0; i < arr.size(); i++) {\n if (isDistinct(arr, i)) {\n distinctCount++;\n if (distinctCount == k) {\n return arr... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int cnt=0;\n for(int i=0;i<arr.size();i++){\n if(count(arr.begin(),arr.end(),arr[i])==1) cnt++;\n if(cnt==k) return arr[i];\n }\n return \"\";\n }\n};",
"memory": "15700"... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int count = 0;\n int n = arr.size();\n for(int i = 0; i < n; i++) {\n bool flag = true;\n for(int j = 0; j < n; j++) {\n if (arr[i] == arr[j] && j != i) {\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int count=0;\n for(int i=0;i<arr.size();i++)\n {\n string str=arr[i];\n int flag=0;\n for(int j=0;j<arr.size();j++)\n {\n if(i!=j && ar... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n vector<bool> isDistinct(arr.size(), true);\n int ind = 0;\n int cnt = 0;\n for (int i = 0; i < arr.size(); i++) {\n if (isDistinct[i]) {\n for (int j = i + 1; j < arr.size... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n vector<int>res;\n for(int i=0;i<arr.size();i++){\n int nb=0;\n for(int j=0;j<arr.size();j++){\n if(arr[i]==arr[j]){\n nb++;\n }\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n string ans;\n vector<int> hash(arr.size(), 0);\n for (int i = 0; i < arr.size(); i++) {\n for (int j = 0; j < arr.size(); j++) {\n if (arr[i] == arr[j]) {\n ha... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n string ans;\n vector<int> hash(arr.size(), 0);\n for (int i = 0; i < arr.size(); i++) {\n for (int j = 0; j < arr.size(); j++) {\n if (arr[i] == arr[j]) {\n ha... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n string ans;\n vector<int> hash(arr.size(), 0);\n for (int i = 0; i < arr.size(); i++) {\n for (int j = 0; j < arr.size(); j++) {\n if (arr[i] == arr[j]) {\n ha... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& a, int k) {\n stack<string> d;\n for (int i=0;i<a.size();i++){\n d.push(a[i]);\n for (int j=0;j<a.size();j++){\n if(i!=j){ if (a[i]==a[j]){ d.pop();break; }}\n }\n if (... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n \n string ret = \"\";\n \n int a[1001];\n \n memset(a, 0, sizeof(a));\n \n int cnt = 0;\n \n for (int i = 0;i < arr.size();i ++)\n {\n if... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n static inline uint64_t c2i(const string::value_type c, unsigned shift) {\n return ((uint64_t)c) << shift;\n }\n static inline uint64_t s2i(const string& s) {\n switch (s.size()) {\n case 0:\n assert(0);\n return 0;\n cas... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n vector<string> num = {};\n for (int i = 0; i < arr.size(); i++) {\n for(int j=i+1;j<arr.size();j++){\n if(arr[i]==arr[j]){\n num.push_back(arr[i]);\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n vector<string> answer;\n for(auto& a:arr)\n {\n if(count(arr.begin(),arr.end(),a) == 1)answer.push_back(a);\n if(answer.size()==k)return a;\n }\n return \"\";\n }\n}... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int count=0;\n unordered_set<string> s;\n for(int i=0;i<arr.size();i++){\n if(find(arr.begin()+i+1,arr.end(),arr[i])==arr.end() && s.find(arr[i])==s.end()){\n count++;\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n stack<string>st;\n int n=arr.size();\n bool flag[n];\n for(int i=0;i<n;i++)\n flag[i]=false;\n for(int i=0;i<n;i++)\n {\n bool dist=true;\n if(!flag[i... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n static string kthDistinct(vector<string>& arr, int k) {\n const int n=arr.size();\n vector<string> sorted(arr.begin(), arr.end());\n sort(sorted.begin(), sorted.end());\n\n for(string& s: arr){\n int i=lower_bound(sorted.begin(), sorted.... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n vector<string>v;\n for(int i=0;i<arr.size();i++)\n {\n int c=0;\n for(int j=0;j<arr.size();j++)\n {\n if(arr[i]==arr[j])\n {\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int n=arr.size();\n //sort(arr.begin(),arr.end());\n vector<string> ans;\n for(int i=0;i<n;i++)\n { int count=0;\n for(int j=0;j<n;j++){\n if(arr[i]==arr[j])\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int n = arr.size();\n vector<string> distinctStrings;\n\n // Iterate through each string in the array\n for (int i = 0; i < n; i++) {\n string currentString = arr[i];\n bool i... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n if(arr.size() == 1)\n return arr[0];\n vector <string> v;\n int count = 0;\n bool flag;\n for(int i=0; i<arr.size(); i++)\n { \n flag = false;\n for(int... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\n\npublic:\n\n string kthDistinct(vector<string>& arr, int k) {\n\n int n = arr.size();\n\n vector<string> distinctStrings;\n\n // Iterate through each string in the array\n\n for (int i = 0; i < n; i++) {\n\n string currentString = arr[i];\n\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n vector<string> ansarr;\n for(int i=0;i<arr.size();i++) {\n string temp=arr[i];\n int count=0;\n for(int j=0;j<arr.size();j++) {\n if(temp==arr[j]) {\n coun... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n vector<string> ansarr;\n for(int i=0;i<arr.size();i++) {\n string temp=arr[i];\n int count=0;\n for(int j=0;j<arr.size();j++) {\n if(temp==arr[j]) {\n coun... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n const int C = 1E9+7;\n\n long long hashString(string& s) {\n long long h = 0;\n for (char c : s)\n h = (h * C + c) % (1 << 31);\n return h;\n }\n\n string kthDistinct(vector<string>& arr, int k) {\n map<int, int> seen;\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_set<string> distinctStrings;\n unordered_set<string> duplicateStrings;\n\n for(auto& str : arr){\n if(duplicateStrings.count(str)){\n continue;\n }\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_set<string> checkUnique, checkDup;\n for(int i=0; i<arr.size(); i++) {\n if(checkUnique.find(arr[i])==checkUnique.end()) {\n checkUnique.insert(arr[i]);\n } else {\... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n // map<string, int> mpp;\n // for(string s: arr){\n // mpp[s]++;\n // }\n // int count =0;\n // string ans = \"\";\n // for(auto it: arr){\n // if(mpp[it] ==1){\... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n map<string,int> m;\n for (string& s : arr) m[s]++;\n for (string& s : arr) if (m[s] == 1 && k-- == 1) return s;\n return \"\";\n }\n};",
"memory": "18100"
} |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n map<string, int> strings;\n for (auto& s : arr) ++strings[s];\n\n int i = 0;\n for (; i < arr.size(); ++i) {\n if (strings[arr[i]] == 1) --k;\n if (k == 0) return arr[i];\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string,int>mp;\n for(int i=0;i<arr.size();i++)\n {\n mp[arr[i]]++;\n }\n for(int i=0;i<arr.size();i++)\n {\n if(k>0 && mp[arr[i]]==1)\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "\nclass Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n map<string, int> mp;\n for(int i = 0; i < arr.size(); i++){\n mp[arr[i]]++;\n }\n \n int count = 0;\n for(int i = 0; i < arr.size(); i++) {\n if(mp[arr[i]] == ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 0 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string, int> strings;\n for (auto& s : arr) ++strings[s];\n\n int i = 0;\n for (; i < arr.size(); ++i) {\n if (strings[arr[i]] == 1) --k;\n if (k == 0) return ar... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 1 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string,int> map;\n for(string s:arr){\n map[s]++;\n }\n for(string s:arr){\n if(map[s] == 1){\n k--;\n }\n if(k == 0){\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 1 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string, int> counter;\n for(const string& str:arr){\n counter[str]++;\n }\n for(const string& str:arr){\n if(counter[str]==1)\n k--;\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 2 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string,int>mp;\n for(string st: arr){\n mp[st]++;\n }\n for(string st: arr){\n if(mp[st]==1 && k==1){\n return st;\n }else if(mp[st]==1... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 2 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string, int> strings;\n strings.reserve(arr.size());\n for (auto& s : arr) ++strings[s];\n\n int i = 0;\n for (; i < arr.size(); ++i) {\n if (strings[arr[i]] == 1) -... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n std::unordered_map<std::string, int> m1;\n std::vector<int> res;\n\n for (auto& s : arr) { ++m1[s]; }\n\n for (std::size_t i = 0; i < arr.size(); ++i) {\n if (m1[arr[i]] == 1) {\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n std::unordered_map<std::string, int> m1;\n std::vector<int> res;\n\n for (auto& s : arr) { ++m1[s]; }\n\n for (std::size_t i = 0; i < arr.size(); ++i) {\n if (m1[arr[i]] == 1) { res.push... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n std::unordered_map<std::string, int> m1;\n std::vector<int> res;\n\n for (auto& s : arr) { ++m1[s]; }\n\n for (std::size_t i = 0; i < arr.size(); ++i) {\n if (m1[arr[i]] == 1) {\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n\n unordered_map<string,int> m;\n for(int a=0;a<arr.size();a++)\n m[arr[a]]+=1;\n vector<int> index;\n for(int a=0;a<arr.size();a++)\n {\n if(m[arr[a]]==1)\n inde... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n stack<string> results;\n unordered_map<string, int> hash;\n for(int i = 0; i<arr.size(); i++) {\n if (hash.count(arr[i]) == 0) {\n hash.insert({arr[i], 0});\n } else {... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string, pair<int, int>>mp;\n int n=arr.size();\n for(int i=0; i<n; i++){\n if(mp.find(arr[i])==mp.end()){\n mp[arr[i]]={i, 1};\n }\n else{\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string,pair<int,int>> um;\n for(int i=0;i<arr.size();i++){\n um[arr[i]].first++;\n um[arr[i]].second=i;\n }\n vector<pair<int,int>> v;\n for(auto i:um){\n... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n \n vector<int> ans(arr.size(),0);\n unordered_map<string,int> map;\n for(int i=0;i<arr.size();i++){\n map[arr[i]]++;\n }\n for(int i=0;i<arr.size();i++){\n if(map... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n map<string,int>mp;\n vector<string>res;\n for(string x : arr) {\n mp[x]++;\n }\n for(auto x : arr) {\n if(mp[x]==1) res.push_back(x);\n if(res.size()==k) r... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string,int> mp;\n for(auto x:arr)\n {\n mp[x]++;\n }\n stack<string> s;\n for(auto x:arr)\n {\n if(mp[x]==1)\n s.push(x);\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string,int> db;\n queue<string> q;\n\n for(auto s: arr){\n if(db.find(s)==db.end()){\n db[s] = 1;\n q.push(s);\n }\n else{\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string, int> mp;\n int n = arr.size();\n for (auto& it : arr) {\n mp[it]++;\n }\n\n vector<string> v;\n for (int i = 0; i < n; i++) {\n if (mp[arr[... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string> arr, int k) {\n unordered_map<string, int> memory;\n for (int i = 0; i < arr.size(); i++) {\n memory[arr[i]]++;\n }\n int count = 0;\n for(string& s: arr){\n if (memory[s]==1) k--;... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string> arr, int k) {\n unordered_map<string, int> memory;\n for (int i = 0; i < arr.size(); i++) {\n memory[arr[i]]++;\n }\n int count = 0;\n for(string& s: arr){\n if (memory[s]==1) k--;... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n int n = arr.size();\n\n unordered_map<string,pair<int,int>> mp;\n int curr = 0;\n\n for(int i=0;i<n;i++)\n {\n string s = arr[i];\n\n if(mp.find(s)==mp.end())\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n map<string,int>mp;\n vector<string>v;\n for(const auto& i:arr)\n {\n mp[i]++;\n }\n \n for (const auto& str : arr) {\n if (mp[str] == 1) {\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string, int> freq;\n for(const string& s : arr){\n freq[s]++;\n }\n\n vector<string> distinct;\n for(const string& s : arr){\n if(freq[s] == 1){\n ... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n map<string,int>mp;\n for(auto i:arr) mp[i]++;\n vector<string>t;\n for(auto i:arr){\n if(mp[i]==1) t.push_back(i);\n }\n if(t.size()<k) return \"\";\n return t[k-1];... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n string kthDistinct(vector<string>& arr, int k) {\n unordered_map<string, vector<int>> m; // str --- index of array\n vector<int> t; // index - str\n\n for (int i = 0; i < arr.size(); i++) {\n m[arr[i]].push_back(i);\n }\n\n for (a... |
2,163 | <p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are... | 3 | {
"code": "class Solution {\npublic:\n// hare krishna\n string kthDistinct(vector<string>& arr, int k) {\n // map<string, int>m;\n // vector<string>hare;\n // for(auto it: arr)\n // {\n // if(m.find(it)!= m.end())\n // {\n // m.erase(it);\n //... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\n static constexpr int len(unsigned a)\n {\n if (a < 10) return 1;\n if (a < 100) return 2;\n if (a < 1000) return 3;\n if (a < 10000) return 4;\n if (a < 100000) return 5;\n if (a < 1000000) return 6;\n if (a < 10000000) return 7;\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n const auto digits = [&](int a, char* arr) {\n auto end = arr;\n do {\n *end++ = a % 10;\n } while (a /= 10);\n while (end > arr && mapping[en... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n std::sort(nums.begin(), nums.end(), [&](const int& a, const int& b) {\n return getMappedNumber(a, mapping) < getMappedNumber(b, mapping); \n });\n return nums;\n }\n\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int> nums) {\n // Lambda function to map the number according to the mapping\n auto mapped = [&](int num) {\n int mapped_num = 0;\n int place = 1;\n do {\n mappe... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n int get_mapped(int num, vector<int>& mapping) {\n int res = 0;\n int m = 1;\n\n if (num == 0) {\n return mapping[num];\n }\n\n while (num != 0) {\n int d = num % 10;\n d = mapping[d];\n res = d*m +... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "int int_to_new(const vector<int> &mapping, int i) {\n int ans = 0;\n int tens = 1;\n do {\n ans += mapping[i % 10] * tens;\n i /= 10;\n tens *= 10;\n } while(i);\n return ans;\n}\n\nclass Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>&... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "bool sortHelper(pair<int, int> i, pair<int, int> j) { return i.first < j.first; }\n\nclass Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n int n = nums.size();\n vector<pair<int, int>> mappedNums(n);\n\n // Map all numbers\n int mult... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "bool sortHelper(pair<int, int> i, pair<int, int> j) { return i.first < j.first; }\n\nclass Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n int n = nums.size();\n vector<pair<int, int>> mappedNums(n);\n\n // Map all numbers\n int mult... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n int convert(vector<int>&mapping,int n){\n if(n==0){\n return mapping[n];\n }\n int ans=0;\n int mul=1;\n while(n!=0){\n int rem=n%10;\n ans=ans+mapping[rem]*mul;\n n/=10;\n mul*=10;\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<pair<int, int>> mappedNums(nums.size());\n for (int indx = 0; indx < nums.size(); ++indx) {\n mappedNums[indx] = {getMappedNumber(nums[indx], mapping), nums[indx]};\n }... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\nprivate:\n int converted(vector<int>& mapping, int num){\n string ans;\n int result = 0;\n if (num == 0) return mapping[0];\n while(num>0){\n int temp = num%10;\n ans.push_back('0'+mapping[temp]);\n num = num/10;\n }\n... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<int> nums2=nums;\n vector<pair<int,int>> nums1(nums.size());\n for(int i=0;i<nums.size();i++){\n nums1[i].first=0;\n }\n for(int i=0;i<nums.size();i++){\n... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n int numCount = nums.size();\n vector<pair<int, int>> mappedNumAndIndex(numCount);\n\n for (int i = 0; i < numCount; ++i) {\n int originalNum = nums[i];\n string mappedNumStr = \"\";\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 0 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n int numCount = nums.size();\n vector<pair<int, int>> mappedNumAndIndex(numCount);\n for (int i = 0; i < numCount; ++i) {\n int originalNum = nums[i];\n string mappedNumStr = \"\";\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 1 | {
"code": "class Solution {\n int Convert(std::vector<int>& mp, int x) {\n if (x == 0) {\n return mp[x];\n }\n\n int res = 0;\n for (int i = 1; x > 0; i *= 10) {\n auto [q, r] = std::div(x, 10);\n res += mp[r] * i;\n x = q;\n }\n\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 1 | {
"code": "class Solution {\n public:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<pair<int, int>> v;\n for (int i = 0; i < nums.size(); ++i) {\n if (nums[i] == 0) {\n v.push_back({mapping[nums[i]], nums[i]});\n continue;\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 1 | {
"code": "bool compare(const pair<int, int>& a,const pair<int, int>& b){\n return a.first<b.first;\n}\n\nclass Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<pair<int, int>> ans;\n for(int i=0;i<nums.size();i++){\n int temp = 0;\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 1 | {
"code": "class Solution {\npublic:\n int mappedNum (int n, vector <int> &mapping) {\n string res = \"\";\n string num = to_string(n);\n\n for (char i : num) {\n res += to_string(mapping[i - '0']);\n }\n\n return stoi(res);\n }\n\n static bool customSort (pair <... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<int> res;\n int m = nums.size();\n \n for (int i = 0; i < m; i++) {\n int t = nums[i];\n string r = \"\";\n if (t == 0) {\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "#include <vector>\n#include <string>\n#include <algorithm>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n // Lambda function to compute the mapped value of a number\n auto getMappedValue = [&](int num) -> long long ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "class Solution {\npublic:\n static bool comp(pair<long long ,long long > a, pair<long long ,long long > b)\n {\n return a.first<b.first;\n\n }\n\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<pair<long long ,long long>> v;\n for(int i=0;i<nums... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<pair<long long, int>> mappedNums;\n int n = nums.size();\n\n // Convert each number in nums based on the mapping\n for (int i = 0; i < n; i++) {\n long long mapp... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "class Solution {\npublic:\n\n long long getval(int num, vector<int> & mapping){\n if(num==0) return mapping[0];\n\n long long mv=0;\n long long factor=1;\n\n while(num>0){\n int d= num%10;\n mv+= mapping[d]*factor;\n factor*=10;\n n... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "class Solution {\npublic:\n long long mapping_fn(vector<int>& mapping, int num) {\n vector<int> ret_digits;\n int factor = 1;\n long long ret = 0;\n if (num == 0)\n return mapping[0];\n\n while (num > 0) {\n int digit = num % 10;\n ret ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n int n = nums.size();\n unordered_map<int, int> mappedValues (n * 2);\n for (int i = 0; i < n; i++) {\n int t = 0, c = nums[i];\n int k = 1;\n if (c == 0)... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums)\n {\n vector <vector <char>> numChar(nums.size());\n vector <pair <int,int>> toSort;\n vector <int> res;\n for (int i = 0; i < nums.size(); i++)\n {\n string s = to_string(nums[i]);\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "\nauto init = [](){\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n return 0;\n}();\n\n\nclass Solution {\n\nstatic int inline convert(const vector<int>& mapping, int num) {\n int res = 0;\n int fact = 1;\n\n do {\n res += mapping[num % 10]*fact;\n fact *= 1... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 2 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n unordered_map<int, int> mapped;\n for (int& num : nums) {\n int newNum = 0;\n int curNum = num;\n int power = 1;\n do {\n newNum += po... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 3 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<string> num(nums.size());\n vector<int> new_nums(nums.begin(),nums.end());\n int j=0;\n for(int i=0;i<nums.size();i++) num[i]=to_string(nums[i]);\n for(int i=0;i<num... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 3 | {
"code": "class Solution {\nprivate:\n unordered_map<int, int> mp;\n long getmapped(int a, vector<int> &mapping){\n auto it = mp.find(a);\n if(it != mp.end()) return it->second;\n string sa = to_string(a);\n string re = \"\";\n for(char c : sa){\n re += to_string(m... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 3 | {
"code": "vector<int> mp;\nunordered_map<int, int> mapp;\nclass Solution {\npublic:\n static int change(int a){\n int tmp = a;\n int n = 0, i = 0;\n if(a == 0)\n return mp[0];\n while(tmp > 0){\n int rem = tmp%10;\n n += mp[rem] * pow(10, i);\n ... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 3 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n int n = nums.size();\n map<int,int> mp;\n for(int i=0;i<n;i++){\n int curr = nums[i];\n int new_num = 0;\n int j=0;\n do{\n int... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 3 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<int> ans;\n unordered_map<int, int> mpp;\n for (int i = 0; i < mapping.size(); i++) {\n mpp[i] = mapping[i];\n }\n for (int i : nums) {\n int n... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 3 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector<int> ref;\n \n for(int x : nums) {\n if (x == 0) {\n ref.push_back(mapping[0]);\n continue;\n }\n \n stri... |
1,333 | <p>You are given a <strong>0-indexed</strong> integer array <code>mapping</code> which represents the mapping rule of a shuffled decimal system. <code>mapping[i] = j</code> means digit <code>i</code> should be mapped to digit <code>j</code> in this system.</p>
<p>The <strong>mapped value</strong> of an integer is the ... | 3 | {
"code": "class Solution {\npublic:\n vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n vector <int> answer(nums.size()); \n vector <vector<int>> trans(nums.size(),vector<int> (3));\n vector <int> copiednums = nums;\n for (int i =0; i < nums.size();i++)\n {\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.