id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,436 | <p>You are given an array <code>nums</code> and an integer <code>k</code>. You need to find a <span data-keyword="subarray-nonempty">subarray</span> of <code>nums</code> such that the <strong>absolute difference</strong> between <code>k</code> and the bitwise <code>OR</code> of the subarray elements is as<strong> small... | 3 | {
"code": "class Solution {\npublic:\n // O(30*N) - Time complexity\n int minimumDifference(vector<int>&nums, int k){\n int n=nums.size();\n unordered_set<int>prev;\n int ans=INT_MAX;\n\n for(int i=0; i<n; i++){\n unordered_set<int>curr;\n for(auto it: prev){\n ... |
3,436 | <p>You are given an array <code>nums</code> and an integer <code>k</code>. You need to find a <span data-keyword="subarray-nonempty">subarray</span> of <code>nums</code> such that the <strong>absolute difference</strong> between <code>k</code> and the bitwise <code>OR</code> of the subarray elements is as<strong> small... | 3 | {
"code": "class Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n unordered_map<int,bool> prev;\n int ans=INT_MAX; \n for(int i=nums.size()-1;i>=0;i--){\n unordered_map<int,bool> curr;\n curr[nums[i]]=true;\n ans=min(ans,abs(k-nums[i])... |
3,436 | <p>You are given an array <code>nums</code> and an integer <code>k</code>. You need to find a <span data-keyword="subarray-nonempty">subarray</span> of <code>nums</code> such that the <strong>absolute difference</strong> between <code>k</code> and the bitwise <code>OR</code> of the subarray elements is as<strong> small... | 3 | {
"code": "class Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n int n = nums.size();\n unordered_set<int> feasible;\n int mini = INT_MAX;\n for(int i=n-1; i>=0; i--){\n unordered_set<int> new_feasible;\n for(auto j : feasible){\n ... |
3,436 | <p>You are given an array <code>nums</code> and an integer <code>k</code>. You need to find a <span data-keyword="subarray-nonempty">subarray</span> of <code>nums</code> such that the <strong>absolute difference</strong> between <code>k</code> and the bitwise <code>OR</code> of the subarray elements is as<strong> small... | 3 | {
"code": "class Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n set<int> s;\n s.insert(0);\n int n=nums.size();\n int ans=INT_MAX;\n for(int i=0;i<n;i++)\n {\n set<int> sn;\n for(auto el:s)\n {\n sn... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 0 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n while(true){\n bool flag = false;\n for(int i=0; i<s.size(); i++){\n if(isdigit(s[i])){\n flag = true;\n for(int j=i-1; j>=0; j--){\n if(!... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 0 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n int n=s.size(), j=0;\n string res=\"\";\n for(int i=0;i<n;i++){\n if( s[i]>='0' && s[i]<='9'){\n if(res.size()!=0){\n res.pop_back();\n }\n }else{\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 0 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n // Continue until there are digits in the string\n while (true) {\n int digitIndex = -1;\n // Find the first digit\n for (int i = 0; i < s.size(); ++i) {\n if (isdigit(s[i])) {\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 0 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n string ans;\n for(char c:s){\n if(isdigit(c)){\n if(!ans.empty()) ans.pop_back();\n }\n else {\n ans.push_back(c);\n }\n }\n return ans;\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 0 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n string ans=\"\";\n for(char ch:s){\n if(!ans.empty() && isalpha(ans.back()) && isdigit(ch) ){\n ans.pop_back();\n }else{\n ans.push_back(ch);\n }\n }\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 0 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n \n int l = s.length();\n\n for (int i = 0; i < l; i++) {\n if (isdigit(s[i])) {\n if (i != 0) {\n s.erase(i-1, 2); l -= 2; i -= 2; }\n else { s.erase(i, 2); l--; ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 0 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n int j=0 ;\n for(int i=0 ; i<s.length();i++){\n if(isdigit(s[i])){\n j--;\n }else{\n s[j]=s[i];\n j++;\n }\n }\n return s.substr(0,j);\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 0 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n \n int i = 0;\n string result;\n while (i < s.size())\n {\n if (!isdigit(s[i]))\n {\n result+= s[i];\n }\n else\n {\n resul... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 1 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n int n=s.size();\n string ans=\"\";\n for(int i=0;i<n;i++){\n if(isdigit(s[i])){\n ans.pop_back();\n }\n else{\n ans.push_back(s[i]);\n }\n }... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 1 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n int n=s.size();\n string ans;\n for(int i=0;i<n;i++){\n if(isdigit(s[i])){\n ans.pop_back();\n }\n else{\n ans.push_back(s[i]);\n }\n }\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 1 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n int j = 0;\n\n for (int i = 0; i < s.length(); i++) {\n if (isdigit(s[i])) {\n j--;\n } else {\n s[j++] = s[i];\n }\n }\n\n return s.substr(0, j);\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 1 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n vector<char> v;\n for(auto i : s){\n (i >= '0' and i <= '9') ? v.pop_back() : v.push_back(i);\n }\n string x;\n for(auto i : v) x.push_back(i);\n return x;\n }\n};",
"memory": "8200"
} |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 1 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n vector<char> vec;\n for(int x:s)\n {\n if(x>47 && x<59)\n {\n vec.pop_back();\n continue;\n }\n vec.push_back(x);\n }\n string ans;\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 1 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n int n=s.length();\n vector<bool> p(n,true);\n\n for(int i=0;i<n;i++)\n {\n if(s[i]>='0' && s[i]<='9')\n {\n p[i]=false;\n int j=i-1;\n while(j>=0)\n... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 1 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n int n=s.length();\n vector<char> ch;\n for(int i=0;i<n;i++)\n {\n if(isdigit(s[i]))\n {\n if(!ch.empty())\n ch.pop_back();\n }\n else\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 1 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n stack<char>d;\n for(int i=0;i<s.length();i++){\n if(isdigit(s[i])){\n d.pop();\n }\n else{\n d.push(s[i]);\n }\n }\n string ans = \"\";\n... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 2 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n stack<char> st;\n for(int i=0;i<s.size();i++){\n char ch = s[i];\n if(ch>='a' && ch<='z'){\n st.push(ch);\n }\n else{\n st.pop();\n }\n }... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 2 | {
"code": "class Solution {\npublic:\n \n string clearDigits(string s) {\n stack<char>st;\n\n for(int i=0; i<s.length(); i++)\n {\n if(isdigit(s[i])) st.pop();\n else\n st.push(s[i]);\n }\n\n int n = st.size();\n\n for (int i = n - ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 2 | {
"code": "class Solution {\npublic:\n \n string clearDigits(string s) {\n stack<char>st;\n for(int i=0; i<s.length(); i++)\n {\n if(isdigit(s[i])) st.pop();\n else\n st.push(s[i]);\n }\n int n = st.size();\n for (int i = n - 1; i >... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 2 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n stack<char>st;\n for(int i=0;i<s.length();i++)\n {\n if(!isdigit(s[i]))\n st.push(s[i]);\n else\n st.pop();\n }\n string t=\"\";\n while(!st.empty())\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 2 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n set<int> st;\n for(int i = s.size()-1;i>=0;i--){\n if(isdigit(s[i])){\n st.insert(i);\n for(int j=i-1;j>=0;j--){\n if(isalpha(s[j]) && st.find(j) == st.end()){\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n stack<char>st;\n for(int i=0;i<s.size();i++)\n {\n st.push(s[i]);\n if(isdigit(s[i]))\n {\n st.pop();\n if(isalpha(st.top()))\n {\n st.pop();\n \... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "class Solution {\npublic:\n bool isNum(char c){\n return( c <='9' && c>='1' || c=='0');\n }\n bool isChar(char c){\n return( c <='z' && c>='a');\n }\n string clearDigits(string s) {\n stack<char>st; \n for (int i=0;i<s.length();i++){\n if (isNum(s[i])){... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n stack<char>st;\n for(int i=0; i<s.size(); i++){\n if(!st.empty() && s[i]>='0' && s[i]<='9'){\n st.pop();\n }else{\n st.push(s[i]);\n }\n }\n if(st.empty... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n stack<char>st;\n for(int i=0; i<s.size(); i++){\n if(!st.empty() && s[i]>='0' && s[i]<='9'){\n st.pop();\n }else{\n st.push(s[i]);\n }\n }\n if(st.empty... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n string ans = \"\";\n stack<char> st;\n for(char ch: s){\n if((int)ch >= 48 && (int)ch <= 57){\n st.pop();\n }\n else st.push(ch);\n }\n while(!st.empty()){\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "class Solution {\npublic:\n string clearDigits(string s) {\n stack<char> St;\n stack<char> reverse_s;\n\n for(int i=0; s[i]!='\\0' ; i++)\n {\n if(isalpha(s[i]))\n {\n St.push(s[i]);\n }\n if(isdigit(s[i]))\n ... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "class Solution {\npublic:\n \n string clearDigits(string s) {\n stack<char>st;\n for(int i=0; i<s.length(); i++)\n {\n if(isdigit(s[i])) st.pop();\n else\n st.push(s[i]);\n }\n int n = st.size();\n for (int i = n - 1; i >... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "class Solution {\npublic:\n \n string clearDigits(string s) {\n stack<char>st;\n for(int i=0; i<s.length(); i++)\n {\n if(isdigit(s[i])) st.pop();\n else\n st.push(s[i]);\n }\n int n = st.size();\n for (int i = n - 1; i >... |
3,447 | <p>You are given a string <code>s</code>.</p>
<p>Your task is to remove <strong>all</strong> digits by doing this operation repeatedly:</p>
<ul>
<li>Delete the <em>first</em> digit and the <strong>closest</strong> <b>non-digit</b> character to its <em>left</em>.</li>
</ul>
<p>Return the resulting string after remov... | 3 | {
"code": "bool IsDigit(char a)\n{\n string digits = {\"1234567890\"};\n for(int i = 0; i < digits.length(); i++)\n if(a == digits[i]) return true;\n return false;\n}\n\nclass Solution {\npublic:\n string clearDigits(string s) \n {\n int l = s.length();\n for(int i = 0; i < l; i++)... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 0 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int highest = skills[1] > skills[0];\n int count = 1;\n for (int i = 2; i < skills.size(); i++) {\n if (count >= k)\n return highest;\n if (skills[highest] > skills... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 0 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n=skills.size(), cnt=0, mx=skills[0], idx=0;\n for(int i=1;i<n;i++){\n if(skills[i]<mx){\n cnt++;\n if(cnt>=k){\n return idx;\n }... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 1 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n = skills.size();\n\n stack<pair<int,pair<int,int>>> st;\n\n for(int i=0;i<n;i++){\n if(st.empty()){\n st.push({skills[i],{0,i}});\n }\n else{\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 1 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n = skills.size();\n\n stack<pair<int,pair<int,int>>> st;\n\n for(int i=0;i<n;i++){\n if(st.empty()){\n st.push({skills[i],{0,i}});\n }\n else{\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 1 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n if (k >= skills.size()) {\n return ranges::max_element(skills) - skills.begin();\n } else if (k == 1) {\n return skills[0] > skills[1] ? 0 : 1;\n }\n vector<int> pos(skills... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 1 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int i = 1, n = skills.size()-1, c = 0;\n if(k >= n) {\n return max_element(skills.begin(), skills.end()) - skills.begin();\n }\n vector<int> I(n+1); iota(I.begin(), I.end(), 0);\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 1 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n = skills.size();\n if (is_sorted(skills.begin(), skills.end())) {\n cout << \"a\";\n if (k == 1) return 1;\n else return n-1;\n }\n vector<int> temp(skills... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 1 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n = skills.size();\n if (is_sorted(skills.begin(), skills.end())) {\n if (k == 1) return 1;\n else return n-1;\n }\n vector<int> temp(skills.begin(), skills.end());\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 1 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n = skills.size();\n int maxSkill = 0;\n int maxIndex = 0;\n for(int i=0; i<n;i++) {\n int s = skills[i];\n if(s >= maxSkill) {\n maxIndex = i;\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 1 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n=skills.size();\n vector<int> v(n+2);\n int maxi=0;\n queue<int> qq;\n int e;\n int cur=0;\n for(int i=0;i+1<n;i++){\n int w,l;\n if(skills[cur]>s... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n if (k>=skills.size()) {\n // Only the highest skill can win\n int result = 0;\n for (int i=0; i<skills.size(); i++) {\n if (skills[i] > skills[result]) result=i;\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& a, int k) {\n int n = a.size(), mx1 = 0;\n k = min(k, n - 1);\n for(int i = 1; i < n; i++){\n if(a[i] > a[mx1]) mx1 = i;\n }\n int mx = mx1;\n vector<int> r(n, 0);\n stack<int> s;\n... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& ss, int k) {\n if (k >= ss.size()-1) {\n int besti = 0;\n for (int i = 1; i < ss.size(); i++) {\n if (ss[i] > ss[besti]) besti = i;\n }\n return besti;\n }\n \n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n if (k >= skills.size())\n {\n int maxe = *max_element(skills.begin(), skills.end());\n for (int i = 0; i < skills.size(); i++)\n {\n if (skills[i] == maxe)\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int maxSkill(vector<int>& skills) {\n int s = INT_MIN, id = -1;\n for(int i = 0; i < skills.size(); i++) {\n if (skills[i] > s)\n s = skills[i], id = i;\n }\n \n return id;\n }\n \n int find(vector<int> &sk... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n=skills.size();\n deque<int>dq;\n for(int i=0;i<n;i++)dq.push_back(i);\n int winner=dq.front();// top index\n dq.pop_front();\n int cnt=0;//it is telling the no of cons, wins\... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n if(k >= skills.size()-1){\n return max_element(skills.begin(),skills.end())-skills.begin();\n }\n deque<int>q;\n for(int i = 0;i<skills.size();i++){\n q.push_back(i);\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& s, int k){\n int n = s.size();\n if(k>=n){\n int maxi = *max_element(s.begin(), s.end());\n return find(s.begin(), s.end(), maxi) - s.begin();\n }\n\n deque<int> q;\n for(auto &it : s)... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "//BEGIN\n\n\ntypedef long long LL;\nstatic const int INF = 1000000000;\nstatic const int P = 1000000007;\n\n#define REP(i,n) for(int i=0;i<(n);i++)\n#define FOR(i,a,b) for(int i=(a);i<=(b);i++)\n#define FORD(i,a,b) for(int i=(a);i>=(b);i--)\n#define pb push_back\n#define ALL(a) a.begin(), a.end()\n#define ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<int>q;\n int n=skills.size();\n int mx=skills[0];\n int ans=0;\n for(int i=0;i<n;i++){\n q.push_back(i);\n if(skills[i]>mx){\n ans=i;\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skill, int k) {\n \n deque<int>q;\n\n int maxIdx=0;\n for(int i=0;i<skill.size();i++)\n {\n q.push_back(i);\n if(skill[i]>skill[maxIdx])\n maxIdx=i;\n }\n\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skill, int k) {\n \n deque<int>q;\n\n int maxIdx=0;\n for(int i=0;i<skill.size();i++)\n {\n q.push_back(i);\n if(skill[i]>skill[maxIdx])\n maxIdx=i;\n }\n\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n = skills.size();\n int i = 0;\n int j = 1;\n int win = 0;\n while (j < 2 * n) {\n if (skills[i] < skills[j]) {\n skills.push_back(skills[i]);\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<int>dq;\n int n=skills.size();\n if(k>=n){\n int m=*max_element(skills.begin(),skills.end());\n for(int i=0;i<n;i++){\n if(m==skills[i])\n retu... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int ans = 0, n = skills.size(); \n unordered_map<int, int > m; \n for(int i = 1; i<n; i++){\n if(skills[i] > skills[ans]){\n ans = i; \n m[i]++;\n }\... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n \n int n = skills.size();\n unordered_map<int, int>mp;\n if(k<n) {\n int maxi=0;\n for(int i=1; i<n;) {\n if(skills[maxi] < skills[i]) {\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n = skills.size(),z = -1;\n int mx = *max_element(skills.begin(),skills.end());\n for(int i = 0; i < n; i++)\n if(skills[i] == mx)\n z = i;\n if(k>=n)return z;\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skill, int k) {\n int n = skill.size();\n deque<int> dp;\n int ans,maxi=0;\n vector<int> wins(n,0);\n for(int i=0;i<n;i++){\n if(skill[i]>maxi){\n ans=i;\n maxi=skil... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int counter = 0;\n std::deque<int> queue(skills.size(), 0);\n for(int i = 1; i != std::ssize(skills); ++i) {\n queue[i] = i;\n }\n int games = std::min(k,static_cast<int>(skill... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& nums, int k) {\n int n= nums.size();\n vector<int>dp(2*n+2);\n int prev = 0;\n for(int i=0;i<nums.size()-1;i++){\n int a1= prev;\n int a= nums[prev], b= nums[i+1];\n if(a>b){\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n // Edge case k larger than n\n if(k >= skills.size()) {\n return distance(skills.begin(), max_element(skills.begin(), skills.end()));\n }\n int winstreak = 0;\n deque<int> queu... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n // Edge case k larger than n\n if(k >= skills.size()) {\n return distance(skills.begin(), max_element(skills.begin(), skills.end()));\n }\n int winstreak = 0;\n deque<int> queu... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "#include <vector>\n#include <deque>\n#include <utility>\n\nclass Solution {\npublic:\n int findWinningPlayer(std::vector<int>& skills, int k) {\n int n = skills.size();\n if (k >= n - 1) {\n return std::max_element(skills.begin(), skills.end()) - skills.begin();\n }\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 2 | {
"code": "#include <vector>\n#include <deque>\n#include <utility>\n\nclass Solution {\npublic:\n int findWinningPlayer(std::vector<int>& skills, int k) {\n int n = skills.size();\n if (k >= n - 1) {\n return std::max_element(skills.begin(), skills.end()) - skills.begin();\n }\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n = skills.size();\n vector<int> q(n*4+10), win(n+5, 0);\n int l = 0, r = n-1;\n for(int i = 0; i < n; ++i) q[i] = i;\n int res = -1;\n int mx = 0;\n for(auto v : skills... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<int> dq;\n int n=skills.size();\n vector<int> wins(n,0);\n for(int i=0;i<n;i++){\n dq.push_back(i);\n }\n k=min(k,n);\n while(true){\n int a=dq.f... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<pair<int,int>> dq;\n int maxi = skills[0];\n int maxi_idx = 0;\n for (int i = 0; i < skills.size(); i++) {\n if (skills[i] > maxi) {\n maxi = skills[i];\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n if (k >= skills.size() - 1) {\n return std::max_element(skills.begin(), skills.end()) - skills.begin();\n }\n deque<pair<int,int>> q;\n vector<int> cnt(skills.size(),0);\n for(... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<pair<int,int>>q;\n int n = skills.size();\n for(int i=0;i<n;i++){\n q.push_back({i,0});\n }\n if(k>=n){\n int maxi=-1,index=0;\n for(int i=0;i<skill... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n unordered_map<int,int> mp;\n queue<int> que;\n int maxi = 0;\n for(int i = 1; i < skills.size() ; i++){\n que.push(i);\n if(skills[i] > skills[maxi]){\n maxi... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n unordered_map<int,int> mp;\n queue<int> que;\n int maxi = 0;\n for(int i = 1; i < skills.size() ; i++){\n que.push(i);\n if(skills[i] > skills[maxi]){\n maxi... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<int> q;\n int maxi = 0, maxInd=0;\n for(int i=0;i<skills.size(); i++){\n q.push_back(skills[i]);\n if(maxi<skills[i]){\n maxi = skills[i];\n ma... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) \n {\n unordered_map<int,int>mp;\n deque<int>dq;\n\n int maxi = INT_MIN, idx;\n\n for(int i=0;i<skills.size();i++)\n {\n dq.push_back(i);\n if(skills[i]>maxi)\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<pair<int,int>>dq;\n int n=skills.size();\n for(int i=0;i<n;i++){\n dq.push_back({i,0});\n }\n int i=0;\n while(i<n&&dq.front().second<k){\n int a=dq.front().fir... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int n=skills.size();\n if(k>=n){\n int maxi=INT_MIN;\n int ans=0;\n for(int i=0;i<n;i++){\n if(maxi<skills[i]){\n maxi=skills[i];\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n struct Player {\n int initialIndex = 0;\n int skill = 0;\n int winTimes = 0;\n };\n int findWinningPlayer(vector<int>& skills, int k) {\n Player winner;\n winner.initialIndex = 0;\n winner.skill = skills[0];\n queue<Playe... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n \n std::deque<std::pair<int, int>> dq;\n\n for(int i = 0; i < skills.size(); i++) {\n dq.push_back({i, skills[i]});\n }\n\n int count = 0;\n int idx_won = -1;\n\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<pair<int,int>> dq;\n for (int skill : skills) {\n dq.push_back({skill, 0});\n }\n\n int winningPlayer = -1;\n\n while (true) {\n auto p1 = dq.front();\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n const int n = static_cast<int>(skills.size());\n if (k >= n) {\n auto iter = max_element(skills.begin(), skills.end());\n return static_cast<int>(distance(skills.begin(), iter));\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n const int n = static_cast<int>(skills.size());\n if (k >= n) {\n auto iter = max_element(skills.begin(), skills.end());\n return static_cast<int>(distance(skills.begin(), iter));\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<pair<int,pair<int,int>>> dq;\n \n int n=skills.size();\n for(int i=0;i<n;i++){\n dq.push_back({skills[i],{i,0}});\n }\n \n int mx=*max_element(skills.begin(... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& p, int k) {\n if (k >= p.size() + 1) return max_element(p.begin(), p.end()) - p.begin();\n map<int, int> mp;\n deque<pair<int, int>> a(p.size());\n for (int i = 0; i < p.size(); i++) {\n a[i].first = p[... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& ski, int k) \n {\n\n deque<pair<int,int>>dq;\n\n int maxi=max_element(ski.begin(),ski.end())-ski.begin();\n\n if(k>ski.size())\n return maxi;\n\n map<int,int>frq;\n\n\n for(int i=0;i<ski.size();i+... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& arr, int k) {\n int n = arr.size();\n deque<pair<int,int>> q;\n for(int i = 0; i < n; i++) q.push_back({i,0});\n int x = 2*n;\n while(x--){\n int fpos = q.front().first;\n int fp = arr... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int maxi=*max_element(skills.begin(),skills.end());\n vector<pair<int,int>> v;\n int j=0;\n int n=skills.size();\n int i=0;\n int count=0;\n int val=1;\n // for(int i... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "#include <bits/stdc++.h>\n#include <ext/pb_ds/assoc_container.hpp>\nusing namespace __gnu_pbds;\nusing namespace std;\nusing ll=long long;\ntypedef tree <pair<ll,ll>, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n/*\n order_of_key (k)\n find_by_order(k)\n*/\ntemplat... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n int maxi = INT_MIN;\n for(int i=0;i<skills.size();i++)\n {\n maxi = max(maxi,skills[i]);\n }\n deque<int>dq;\n for(int i=0;i<skills.size();i++)\n {\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<pair<int, int>> dq;\n map<int, int> m;\n int curr=0, ans=0;\n\n \n for (auto it:skills) {\n dq.push_back(pair(it, curr));\n curr++;\n }\n\n curr=... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n if(k >= skills.size()){\n int index = -1;\n int maxi = INT_MIN;\n\n for(int i = 0 ; i < skills.size() ; i++){\n if(skills[i] > maxi){\n index = i;\n... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& nums, int k) {\n \n int n = nums.size();\n if(k>nums.size()){\n return max_element(nums.begin(), nums.end())-nums.begin();\n }\n deque<int> q;\n map<int,int> mp;\n\n for(int i =0 ; ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n vector<pair<int,int>> to_play;\n int ff = 0;\n for (int i = 0; i < skills.size(); i++) {\n to_play.push_back({skills[i], i});\n if (skills[i] > skills[ff]) ff = i;\n }\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n if (k >= skills.size()) {\n return distance(skills.begin(), max_element(skills.begin(), skills.end()));\n }\n int i = 0;\n map<int, int> original_pos;\n int wins = 0;\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution \n{\npublic:\n int findWinningPlayer(vector<int>& skills, int k) \n {\n int n=skills.size();\n if(k>=n)\n {\n int i=0, mx=skills[0];\n for(int x=1; x<n; x++)\n {\n if(mx<skills[x])\n {\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& skills, int k) {\n deque<int> q;\n int size = skills.size();\n int max_s = 0;\n\n for(auto skill : skills) {\n q.push_back(skill);\n max_s = max(max_s,skill);\n }\n \n ma... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& arr, int k) {\n int n = arr.size();\n \n int maxpos = 0;\n\n int maxx = *max_element(arr.begin() , arr.end());\n\n for(int i=0; i<n ; i++){\n if(arr[i]==maxx){\n maxpos = i;\n ... |
3,413 | <p>A competition consists of <code>n</code> players numbered from <code>0</code> to <code>n - 1</code>.</p>
<p>You are given an integer array <code>skills</code> of size <code>n</code> and a <strong>positive</strong> integer <code>k</code>, where <code>skills[i]</code> is the skill level of player <code>i</code>. All ... | 3 | {
"code": "class Solution {\npublic:\n int findWinningPlayer(vector<int>& arr, int k) {\n int n = arr.size();\n \n int maxpos = 0;\n\n int maxx = *max_element(arr.begin() , arr.end());\n\n for(int i=0; i<n ; i++){\n if(arr[i]==maxx){\n maxpos = i;\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.