id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "\n \nclass Solution {\npublic:\n void inorder(TreeNode* root, vector<int> & v){\n if(root==NULL) return ;\n inorder(root->left, v);\n v.push_back(root->val);\n inorder(root->right, v);\n }\n TreeNode* buildBST(vector<int> v, int s, int e){\n if(s>e) return NULL; ... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,285 | <p>Given the <code>root</code> of a binary search tree, return <em>a <strong>balanced</strong> binary search tree with the same node values</em>. If there is more than one answer, return <strong>any of them</strong>.</p>
<p>A binary search tree is <strong>balanced</strong> if the depth of the two subtrees of every nod... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "#pragma GCC optimize(\"O3\", \"unroll-loops\")\nclass Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int loss[100001];\n int xmin=1e6, xmax=0;\n memset(loss, -1, sizeof(loss));\n for (auto& p: matches ) {\n int &x=p[0], &y=... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "#pragma GCC optimize(\"O3\", \"unroll-loops\")\nclass Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int loss[100001];\n int xmin=1e6, xmax=0;\n memset(loss, -1, sizeof(loss));\n for (auto& p: matches ) {\n int &x=p[0], &y=... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int deg[2][100001]={};\n for (auto& e : matches) {\n ++deg[0][e[0]];\n ++deg[1][e[1]];\n }\n vector<vector<int>> res(2,vector<int>());\n for (int i(0); i... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int n=matches.size();\n int l[100001];\n for (int i=0;i<100001;i++) l[i]=-1;\n for (int i=0;i<n;i++) {\n if (l[matches[i][0]]==-1) l[matches[i][0]]=0;\n if (l[m... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution\n{\npublic:\n vector<vector<int>> findWinners(vector<vector<int>> &matches)\n {\n int q = 100000 + 10;\n int arr[q];\n memset(arr, -1, sizeof(arr));\n int n = matches.size();\n \n // Update array based on match outcomes\n for (int i = 0;... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int lose[1000000]={0};\n for(int i=0;i<matches.size();i++){\n lose[matches[i][1]]--;\n }\n vector<int>l;\n for(int i=0;i<1000000;i++){\n if(lose[i]==-1){... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int lose[1000000]={0};\n for(int i=0;i<matches.size();i++){\n lose[matches[i][1]]--;\n }\n vector<int>l;\n for(int i=0;i<1000000;i++){\n if(lose[i]==-1){... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int lose[1000000]={0};\n for(int i=0;i<matches.size();i++){\n lose[matches[i][1]]--;\n }\n vector<int>l;\n for(int i=0;i<1000000;i++){\n if(lose[i]==-1){... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int lose[1000000]={0};\n for(int i=0;i<matches.size();i++){\n lose[matches[i][1]]--;\n }\n vector<int>l;\n for(int i=0;i<1000000;i++){\n if(lose[i]==-1){... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int loss[100001],\n minIdxPlayer = 1e6, maxIdxPlayer = 0,\n winPlayer, lossPlayer;\n \n memset(loss, -1, sizeof(loss));\n\n for(vector<int> match : matches){\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int loss[100001],\n minIdxPlayer = 1e6, maxIdxPlayer = 0,\n winPlayer, lossPlayer;\n \n memset(loss, -1, sizeof(loss));\n for(vector<int> match : matches){\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n bitset<2> loss[100001];\n int minIdxPlayer = 1e6, maxIdxPlayer = 0,\n winPlayer, lossPlayer;\n \n fill(loss, loss + 100001, bitset<2>(0));\n for(vector<int> match :... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int lost[100001] = {0}, ma = 0;\n bool played[100001] = {false};\n for (auto u : matches){\n lost[u[1]]++; played[u[0]] = true; played[u[1]] = true;\n ma = max(ma, max... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int n=matches.size();\n unordered_map<int,int> loses;\n for(int i=0;i<n;i++){\n\n loses[matches[i][1]]++;\n }\n vector<int> onelosers;\n for(auto x:loses){\n... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> out;\n int i;\n\n // Count losses for each player\n for (i = 0; i < matches.size(); i++) {\n out[matches[i][1]]++;\n }\n\n vector<int... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int, int> mp;\n vector<vector<int>> ans(2); \n for(int i=0; i<matches.size(); i++){\n mp[matches[i][1]]++;\n }\n for(int i=0; i<matches.size(); i++){\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int,int>lost;\n for(int i=0;i<matches.size();i++){\n int c=matches[i][1];\n lost[c]++;\n }\n for(auto it:lost){\n cout<<it.first<<it.se... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int,int>lost;\n for(int i=0;i<matches.size();i++){\n int c=matches[i][1];\n lost[c]++;\n }\n for(auto it:lost){\n cout<<it.first<<it.se... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int n=matches.size();\n map<int,int> loses;\n for(int i=0;i<n;i++){\n\n loses[matches[i][1]]++;\n }\n vector<int> onelosers;\n for(auto x:loses){\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n set<int>s;\n vector<vector<int>>result(2);\n unordered_map<int,int>m;\n for(int i=0; i < matches.size();i++)\n m[matches[i][1]]++;\n for(int i=0; i < matches.size()... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int,int>lose;\n for(int i=0;i<matches.size();i++){\n lose[matches[i][1]]--;\n }\n vector<int>l;\n for(auto ptr:lose){\n if(ptr.second==-1){\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int,int>lose;\n for(int i=0;i<matches.size();i++){\n lose[matches[i][1]]--;\n }\n vector<int>l;\n for(auto ptr:lose){\n if(ptr.second==-1){\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "#pragma GCC optimize(\"03\", \"unroll-loops\")\nauto init = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 'c';}();\n\nclass Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int,int> mp;\n for (auto& v : matches) {\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "auto foo = ios_base::sync_with_stdio (false);\n\nclass Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> ls;\n\n for (const auto& m : matches) {\n ls[m[0]] += 0;\n ls[m[1]] += 1;\n }\n\n vecto... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution { // T.C. -> O (n log n), S.C. -> O (n).\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> loss_count;\n\n // Count losses for each player.\n for (vector<int>& match : matches) {\n loss_count[match[1]]++;\n... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>> res(2);\n unordered_map<int,int> mp; //map of losses\n for(int i=0;i<matches.size();i++)\n {\n mp[matches[i][1]]++;\n }\n for(int i=0;i<m... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> dic;\n for (int i = 0; i < matches.size(); ++i) {\n if (!dic.count(matches[i][0])) {\n dic[matches[i][0]] = 0;\n }\n if (!di... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>> result(2);\n unordered_map<int, int> count;\n\n for (const vector<int>& match : matches) {\n count[match[0]] = 0;\n count[match[1]] = 0;\n }... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>> res(2);\n unordered_map<int,int> mp; //map of losses\n for(int i=0;i<matches.size();i++)\n {\n mp[matches[i][1]]++;\n }\n for(int i=0;i<m... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> lossesCount;\n for (auto& match : matches) {\n int winner = match[0], loser = match[1];\n if (lossesCount.find(winner) == lossesCount.end()) {\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> lossesCount;\n for (auto& match : matches) {\n int winner = match[0], loser = match[1];\n if (lossesCount.find(winner) == lossesCount.end()) {\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n \n /*\n \n winner = match[0]\n loser = match[1]\n \n answer[0] -> undefeated\n answer[1] -> lost exactly ONE match\n\n\nThe values in the two lists should... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_set<int> zeroLoss, oneLoss, moreLoss;\n\n for (auto& match : matches) {\n int winner = match[0], loser = match[1];\n // Add winner.\n if ((oneLoss.find(w... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int, int> losers;\n for (auto &match: matches)\n {\n losers[match[1]]++;\n if (!losers.contains(match[0])) losers[match[0]] = 0;\n }\n vector<vector<... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n //unordered_map<int,int> mp;\n map<int,int> mp;\n for(int i=0;i<matches.size();i++){\n mp[matches[i][1]]++;\n }\n vector<vector<int>> answer(2);\n for(int i=... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n \n unordered_map<int, int> lost_map;\n\n // Count how many times each player has lost.\n for(int i = 0; i < matches.size(); i++) {\n int loser = matches[i][1];\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches){\n vector<vector<int>> ans;\n unordered_map<int,int> a;\n for(int i=0;i<matches.size();i++){\n a[matches[i][1]]+=1;\n }\n vector<int> x;\n for(int i=0;i<matches.... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>> ret(2);\n unordered_map<int, int> losers;\n unordered_set<int> winners;\n\n for (int i = 0; i < matches.size(); i++) {\n losers[matches[i][1]]++;\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 0 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) \n {\n int n=matches.size();\n map<int,int>mp;\n vector<vector<int>>res;\n\n for(int i=0;i<n;i++)\n {\n int w=matches[i][0];\n int l=matches[i][1];\n\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int,int>mp;\n for(int i=0;i<matches.size();i++)\n {\n mp[matches[i][1]]++;\n }\n set<int>c;\n vector<int>b;\n for(int i=0;i<matches.size();i++)\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\n /*\n\n [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]\n\n \n [1,2,10] [3,6,7,5,8,9,4]\n unorderd_set<int> winners\n unordered_set<int> losers\n\n 1. If winner beat loser, loser goes into losers\n 2. If winner does not ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& mat) {\n vector<int>no_lose;\n vector<int>one_lose;\n map<int,int>mpp;\n for(int i=0;i<mat.size();i++)\n {\n mpp[mat[i][1]]++;\n }\n set<int>st;\n for(int i=0;i<mat.size();i++)\n {... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_set<int> winners;\n unordered_map<int, int> losers;\n vector<int> noLoss, oneLoss;\n vector<vector<int>> ans;\n \n for(int i = 0; i < matches.size(); i++) {\n... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int,int> noLoss;\n unordered_map<int,int> oneLoss;\n unordered_map<int,int> manyLoss;\n \n for (const auto& match : matches) {\n if (oneLoss.find(matc... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>> ret(2);\n unordered_map<int, std::pair<int,int>> m;\n\n for (int i = 0; i < matches.size(); i++) {\n m[matches[i][0]].first++;\n m[matches[i][1]].s... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> losses;\n unordered_set<int> winners;\n vector<int> noLosses, oneLoss;\n \n // Iterate through matches\n for (const auto& match : matches) {\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_set<int> won;\n unordered_map<int, int> lost;\n\n for(auto &m : matches) {\n auto w = m[0];\n auto l = m[1];\n won.insert(w);\n lost[l]... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>>ans(2);\n int size = matches.size();\n map<int,int>winnerMap,loserMap;\n for (int i=0;i<size;i++) {\n int w = matches[i][0];\n int l = matche... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>>ans(2);\n int size = matches.size();\n map<int,int>winnerMap,loserMap;\n for (int i=0;i<size;i++) {\n int w = matches[i][0];\n int l = matche... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n set<int> noloss, oneloss, others;\n\n for (auto& m : matches) {\n int win = m[0];\n int loss = m[1];\n\n if (others.find(win) == others.end() \n &&... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n //각 플레이어를 키로 하고 패배 횟수를 값으로 하는 hash map 생성 - 반대로 패배 횟수가 키이고 플레이어 배열이 값이라면? 둘다 O(n*m)인듯\n //해시맵 키에 대해서 loop 돌려 값이 0과 1인 경우에만 answer에 추가\n \n unordered_map<int, int> counts;\n ve... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>> ans;\n vector<int> ans_0, ans_1;\n map<int, int> winner, loser;\n \n for (vector<int>& arr: matches) {\n winner[arr[0]]++;\n loser[ar... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int n=matches.size();\n map<int,int>win;\n map<int,int>loss;\n for(int i=0;i<matches.size();i++)\n {\n int w=matches[i][0];\n int l=matches[i][1];\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int,int> winners;\n map<int,int> onetime;\n for(int i=0;i<matches.size();i++)\n {\n winners[matches[i][0]]++;\n onetime[matches[i][1]]++;\n }\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int,int>winners;\n map<int,int>lossers;\n vector<int>play_1;\n vector<int>play_2;\n int m=matches.size();\n for(int i=0;i<m;i++){\n int winner=matches[i]... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int n = matches.size();\n // set<int> winner;\n // set<int> looser;\n // for(int i =0;i<n;i++){\n // for(int j=0;j<2;j++){\n // if(j==0){\n // ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int n = matches.size();\n \n unordered_map<int,int> winner;\n unordered_map<int,int> looser;\n\n for(int i =0;i<n;i++){\n winner[matches[i][0]]++;\n looser[... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n vector<vector<int>> res(2);\n unordered_map<int,int> win,lose;\n for(int i=0;i<matches.size();i++){\n win[matches[i][0]]++;\n lose[matches[i][1]]++;\n }\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> loss;\n int winners = 0;\n int losers = 0;\n for (auto match : matches) {\n if (match.size() == 2) {\n auto &winner = loss[match[0]]... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int,int> win,los;\n for(int i=0;i<matches.size();i++){\n win[matches[i][0]]++;\n los[matches[i][1]]++;\n }\n vector<int> winner,looser;\n\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int,int> win;\n unordered_map<int,int> loose;\n\n for(vector<int> &i : matches) {\n win[i[0]]++;\n loose[i[1]]++;\n }\n vector<int> w;\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, int> losses;\n for (vector<int> match : matches) {\n if (losses.find(match[0]) == losses.end()) {\n losses[match[0]] = 0;\n }\n l... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& nums) {\n int n = nums.size();\n unordered_map<int, int>mp;\n for(auto x:nums){\n mp[x[0]] = 0;\n mp[x[1]] = 0;\n }\n for(int i = 0; i < n; i++){\n mp[nums... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n std::vector<std::vector<int>> ans(2);\n std::unordered_set<int> no_loss;\n std::unordered_set<int> one_loss;\n std::unordered_set<int> mult_loss;\n \n for (std::vector<... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 1 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n int n = matches.size();\n unordered_map<int, int> matches_won, matches_lost;\n vector<int> list1, list2;\n for(vector<int>& match: matches) {\n matches_won[match[0]] ++;\n... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int, pair<int, int>> score;\n vector<vector<int>> answer(2);\n for (auto match:matches) {\n if (score.find(match[0]) == score.end()) {\n score[match[0]].first ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int, pair<int, int>> mp;\n for(auto i : matches){\n mp[i[0]].first++;\n mp[i[1]].second++;\n }\n vector<vector<int>> ans(2);\n for(auto [i, v] : mp){... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n \nint maxi=0;\nfor(int i=0;i<matches.size();i++){\n maxi=max(maxi,matches[i][0]);\n maxi=max(maxi,matches[i][1]);\n}\nvector<int> hash(maxi+1,-1);\n\nfor(int i=0;i<matches.size();i++){\n if(hash... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "#pragma GCC optimize('O3')\nclass Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\n unordered_map<int, int> players;\n for (vector<int> match : matches) {\n int winner = match[0];\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "#pragma GCC optimize('O3')\nclass Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n //ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\n unordered_map<int, int> players;\n for (vector<int> match : matches) {\n int winner = match[0];\... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n \n \n unordered_map<int,int> win,lose;\n \n for(auto arr: matches){\n \n if(lose.find(arr[0])==lose.end()){\n win[arr[0]]++;\n }... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_set<int> seen;\n unordered_map<int, int> lossesCount;\n\n for (auto& match : matches) {\n int winner = match[0], loser = match[1];\n seen.insert(winner);\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n // record winners set, lose count dic\n unordered_map<int, int> lossesCount;\n unordered_set<int> seen;\n vector<vector<int>> res(2);\n for (auto const& match : matches) {\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_set<int> winners;\n unordered_map<int, int> losers;\n vector<int> noLoss, oneLoss;\n vector<vector<int>> ans;\n \n for(vector<int> match : matches) {\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_set<int> winners;\n unordered_map<int, int> losers;\n vector<int> noLoss, oneLoss;\n vector<vector<int>> ans;\n \n for(vector<int> match : matches) {\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n \n vector<vector<int>> result;\n if(matches.size() > 0 && matches.size() <100001){\n set<int> zero_loss;\n set<int> one_loss;\n set<int> more_loss;\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_map<int, pair<int, int>> score;\n vector<vector<int>> answer(2);\n for (auto match:matches) {\n if (score.find(match[0]) == score.end()) {\n score[match[... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) { \n unordered_map<int,int>mLoss;\n unordered_set<int>sPlayers;\n for(vector<int>&match: matches){ \n mLoss[match[1]]++;\n sPlayers.insert(match[0]);\n ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n unordered_set<int> players;\n unordered_map<int,int> losers;\n for (int i = 0; i < matches.size(); i++) {\n losers[matches[i][1]]++;\n if (players.find(matches[i][0]) ... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n std::vector<std::vector<int>> findWinners(std::vector<std::vector<int>>& matches) {\n // Use std::map to keep the keys sorted\n std::map<int, int> lossesCount;\n std::set<int> seen;\n std::vector<std::vector<int>> res(2);\n\n for (auto c... |
1,354 | <p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p>
<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2<... | 2 | {
"code": "class Solution {\npublic:\n vector<vector<int>> findWinners(vector<vector<int>>& matches) {\n map<int,int> loser;\n map<int,int> winner;\n\n for(auto x:matches)\n {\n loser[x[1]]++;\n winner[x[0]]++;\n }\n vector<vector<int>> ans;\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.