id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n long long dp[17][3];\n long long helper(string upper, long long ind, string s, bool tight, long long limit) {\n if (upper.length() < s.length()) return 0;\n if (upper.length() == s.length()) {\n if (upper < s) return 0;\n return 1;\n ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n long long dp[17][3];\n long long helper(string upper,int ind, string s,bool tight,int limit)\n {\n if(upper.length()<s.length())return 0;\n if(upper.length()==s.length())\n {\n if(upper<s)return 0;\n return 1;\n }\n ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n typedef vector<long long> vl;\n typedef vector<vl> vvl;\n unordered_map<int,vl> dp;\n long long numberOfPowerfulInt(long long start, long long end, int limit, string s) {\n string startString = to_string(start-1), endString = to_string(end);\n dp.clear(... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n string target ;\n int l;\n \n long long f(int i ,string mx,bool pass,vector<vector<long long>>&dp) { \n \n if(mx.size()-i == target.size()) {\n if(pass) return dp[i][pass] = 1;\n return dp[i][pass] = (mx.substr(i,mx.size())) >=(target) ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n string target ;\n int l;\n \n long long f(int i ,string mx,bool pass,vector<vector<long long>>&dp) { \n \n if(mx.size()-i == target.size()) {\n if(pass) return dp[i][pass] = 1;\n return dp[i][pass] = (mx.substr(i,mx.size())) >=(target) ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n string target ;\n int l;\n \n long long f(int i ,string mx,bool pass,vector<vector<long long>>&dp) { \n \n if(mx.size()-i == target.size()) {\n if(pass) return dp[i][pass] = 1;\n return dp[i][pass] = (mx.substr(i,mx.size())) >=(target) ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n long long numberOfPowerfulInt(long long start, long long finish, int limit, string s) {\n const std::string a_original = std::to_string(start), b = std::to_string(finish);\n const std::string a = std::string(b.size() - a_original.size(), '0') + a_original;\n ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n long long numberOfPowerfulInt(long long start, long long finish, int limit, string s) {\n const std::string a_original = std::to_string(start), b = std::to_string(finish);\n const std::string a = std::string(b.size() - a_original.size(), '0') + a_original;\n ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n bool sufrest;\n\n long long solve(long long i, long long finish, long long limit, bool rest, long long d){\n if(i==d)\n {\n return !rest || !sufrest;\n }\n\n long long finD = to_string(finish)[i]-'0';\n\n long long maxD = limit... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n string target ;\n int l;\n \n long long f(int i ,string mx,bool pass,vector<vector<long long>>&dp) { \n \n if(mx.size()-i == target.size()) {\n if(pass) return dp[i][pass] = 1;\n return dp[i][pass] = (mx.substr(i,mx.size())) >=(target) ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n string target ;\n int l;\n \n long long f(int i ,string mx,bool pass,vector<vector<long long>>&dp) { \n \n if(mx.size()-i == target.size()) {\n if(pass) return dp[i][pass] = 1;\n return dp[i][pass] = (mx.substr(i,mx.size())) >=(target) ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n long long solve(long long ind, bool tight, string s, long long limit, const string& orig, vector<vector<long long>>& dp) {\n // Base cases\n if (orig.length() < s.length()) return 0;\n if (s.length() == orig.length()) {\n return (stoll(s) <= st... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n long long solve(long long ind, bool tight, string s, long long limit, const string& orig, vector<vector<long long>>& dp) {\n // Base cases\n if (orig.length() < s.length()) return 0;\n if (s.length() == orig.length()) {\n return (stoll(s) <= st... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\npublic:\n string target ;\n int l;\n \n long long f(int i ,string mx,bool pass,vector<vector<long long>>&dp) { \n \n if(mx.size()-i == target.size()) {\n if(pass) return dp[i][pass] = 1;\n return dp[i][pass] = (mx.substr(i,mx.size())) >=(target) ... |
3,243 | <p>You are given three integers <code>start</code>, <code>finish</code>, and <code>limit</code>. You are also given a <strong>0-indexed</strong> string <code>s</code> representing a <strong>positive</strong> integer.</p>
<p>A <strong>positive</strong> integer <code>x</code> is called <strong>powerful</strong> if it en... | 3 | {
"code": "class Solution {\n public:\n long long numberOfPowerfulInt(long long start, long long finish, int limit,\n string s) {\n const string a = to_string(start);\n const string b = to_string(finish);\n const string aWithLeadingZeros = string(b.length() - a.length(), '0') ... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 0 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n int Max=0;\n int D=0;\n for (int i=0;i<dimensions.size();i++){\n if (dimensions[i][0]*dimensions[i][0]+dimensions[i][1]*dimensions[i][1]>Max){\n Max=dimensions[i][0]*dime... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 0 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n double diag = 0, maxDiag = 0;\n int area = 0;\n\n for (vector<int>& dim: dimensions) {\n diag = sqrt((dim[0] * dim[0]) + (dim[1] * dim[1]));\n\n if (diag > maxDiag) {\n ... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 0 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n double diag = 0, maxDiag = 0;\n int area = 0;\n\n for (vector<int>& dim: dimensions) {\n diag = sqrt((dim[0] * dim[0]) + (dim[1] * dim[1]));\n\n if (diag > maxDiag) {\n ... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 0 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n double diag = 0, maxDiag = 0;\n int area = 0;\n\n for (vector<int>& dim: dimensions) {\n diag = sqrt((dim[0] * dim[0]) + (dim[1] * dim[1]));\n\n if (diag > maxDiag) {\n ... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 2 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n int ans = 0, largestDiag = 0;\n for(const auto &dim : dimensions) {\n if(dim[0]*dim[0] + dim[1]*dim[1] > largestDiag) {\n largestDiag = dim[0]*dim[0] + dim[1]*dim[1];\n ... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 2 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\nint b=0;\nint a=0;\nfor(auto&i:dimensions){\n int s=i[0]*i[0]+i[1]*i[1];\n if(s >a){\n a=s;\n b=i[0]*i[1];\n }else if(a==s){\n b=max(b,i[0]*i[1]);\n }\n}\n return b;\n\n }\n};",
... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 2 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimen) {\n float maxdia=0;\n int maxarea=0;\n vector<int>my;\n for(int i=0;i<dimen.size();i++)\n {\n cout<<dimen[i][0]<<\" \"<<dimen[i][1]<<endl;\n float dia=sqrt(pow(dimen[i][... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 2 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n double max = 0.0;\n int result = 0;\n for(int i = 0; i < dimensions.size(); i++){\n if(max < sqrt(dimensions[i][0] * dimensions[i][0] + dimensions[i][1] * dimensions[i][1])){\n ... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 2 | {
"code": "class Solution {\nprivate:\n double diagonalLength(double length,double width){\n return sqrt(length*length + width*width);\n }\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n double max_diagonal = DBL_MIN;\n int max_area =0;\n for(auto it: dimensi... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 2 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n int area=0;\n double dia=0;\n for(auto it:dimensions)\n {\n double res=sqrt(it[0]*it[0]+it[1]*it[1]);\n \n if( dia<res || (dia==res && area<it[0]*it[1]))\n... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 2 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n float maxd = 0;\n int maxa = 0;\n\n for(auto d: dimensions) {\n float newd = sqrt(d[0]*d[0]+d[1]*d[1]);\n int newa = d[0]*d[1];\n // cout<<newd<<\" \"<<maxd<<\"\\n... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 3 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n float max_diagonal = 0;\n int max_area = 0;\n\n for (auto r : dimensions) {\n float x = r.at(0);\n float y = r.at(1);\n\n float diag = sqrt(pow(x, 2) + pow(y, 2));... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 3 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n \n int diag = 0;\n int area = 0;\n\n for(auto d : dimensions){\n\n int t = d[0]*d[0] + d[1]*d[1];\n\n if(t>diag || (t == diag && d[0]*d[1] > area)){\n\n ... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 3 | {
"code": "class Solution {\npublic:\n\n\n\n\n\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n \n double sq = 0;\n int area = 0;\n\n for(auto v : dimensions){\n\n double dig = sqrt(v[0]*v[0]+v[1]*v[1]);\n cout<<dig<<endl;\n if(sq < dig){\n\n... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 3 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n double max=0;\n vector<int> maxd(2);\n for (auto i:dimensions){\n double diag=sqrt(pow(i[0], 2)+pow(i[1], 2));\n if (max<diag){\n max=diag;\n ma... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 3 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n double max=0;\n vector<int> maxd(2);\n for (auto i:dimensions){\n double diag=sqrt(pow(i[0], 2)+pow(i[1], 2));\n if (max<diag){\n max=diag;\n ma... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 3 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dim) {\n \n vector<pair<double,pair<int,int>>>nums;\n \n for(int i = 0;i<dim.size();i++)\n {\n double dig = sqrt(dim[i][0]*dim[i][0]+dim[i][1]*dim[i][1]);\n nums.push_back({dig... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 3 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& d) {\n priority_queue<pair<double, int>> pq;\n for(int i = 0; i<d.size(); i++){\n int area = d[i][0]*d[i][1];\n double diag = sqrt(d[i][0]*d[i][0] + d[i][1]*d[i][1]);\n pq.push({diag, ar... |
3,251 | <p>You are given a 2D <strong>0-indexed </strong>integer array <code>dimensions</code>.</p>
<p>For all indices <code>i</code>, <code>0 <= i < dimensions.length</code>, <code>dimensions[i][0]</code> represents the length and <code>dimensions[i][1]</code> represents the width of the rectangle<span style="font-size... | 3 | {
"code": "class Solution {\npublic:\n int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {\n double maxDiagonal = 0;\n int ans = 0;\n for(auto dim:dimensions) {\n double diagonal = sqrt(dim[0]*dim[0]+dim[1]*dim[1]);\n if(maxDiagonal<=diagonal) {\n maxD... |
3,270 | <p>There is a <strong>1-indexed</strong> <code>8 x 8</code> chessboard containing <code>3</code> pieces.</p>
<p>You are given <code>6</code> integers <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, and <code>f</code> where:</p>
<ul>
<li><code>(a, b)</code> denotes the position of the ... | 0 | {
"code": "class Solution {\npublic:\n int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {\n if(a==e && !((c==e && b < d && d < f) || (c==e && f<d && d<b)))\n {\n return 1;\n }\n if(b==f && !((d==f && a<c && c<e) || (d == f && e<c && c<a)))\n {\n ... |
3,270 | <p>There is a <strong>1-indexed</strong> <code>8 x 8</code> chessboard containing <code>3</code> pieces.</p>
<p>You are given <code>6</code> integers <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, and <code>f</code> where:</p>
<ul>
<li><code>(a, b)</code> denotes the position of the ... | 0 | {
"code": "class Solution {\npublic:\n int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {\n if(a == e && !(a == c && d > min(b,f) && d < max(b,f) )) return 1; //rook and queen in same row\n if(b == f && !(b == d && c > min(a,e) && c < max(a,e) )) return 1; //rook and queen in the... |
3,270 | <p>There is a <strong>1-indexed</strong> <code>8 x 8</code> chessboard containing <code>3</code> pieces.</p>
<p>You are given <code>6</code> integers <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, and <code>f</code> where:</p>
<ul>
<li><code>(a, b)</code> denotes the position of the ... | 0 | {
"code": "class Solution {\npublic:\n int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {\n //1\n if(a==e && b==f) return 0;\n if(c==e && d==f) return 0;\n\n //2\n if(a==e){\n if(c==e){\n if(d>=max(b,f) || d<=min(b,f)) return 1;\n ... |
3,270 | <p>There is a <strong>1-indexed</strong> <code>8 x 8</code> chessboard containing <code>3</code> pieces.</p>
<p>You are given <code>6</code> integers <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, and <code>f</code> where:</p>
<ul>
<li><code>(a, b)</code> denotes the position of the ... | 0 | {
"code": "class Solution {\npublic:\n // time/space: O(1)/O(1)\n int minMovesToCaptureTheQueen(int yRook, int xRook, int yBishop, int xBishop, int yQueen, int xQueen) {\n // try to move the rook in 1 step\n if (xRook == xQueen) {\n // check if the bishop is block the vertical way\n ... |
3,270 | <p>There is a <strong>1-indexed</strong> <code>8 x 8</code> chessboard containing <code>3</code> pieces.</p>
<p>You are given <code>6</code> integers <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, and <code>f</code> where:</p>
<ul>
<li><code>(a, b)</code> denotes the position of the ... | 1 | {
"code": "class Solution {\npublic:\n bool isInside(int a, int b){\n return (a > 0 && a <= 8 && b > 0 && b <= 8);\n }\n int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {\n int tempA = a, tempB = b;\n while(tempA <= 8 && !(tempA == c && tempB == d)){\n ... |
3,270 | <p>There is a <strong>1-indexed</strong> <code>8 x 8</code> chessboard containing <code>3</code> pieces.</p>
<p>You are given <code>6</code> integers <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, and <code>f</code> where:</p>
<ul>
<li><code>(a, b)</code> denotes the position of the ... | 1 | {
"code": "class Solution {\npublic:\n int minMovesToCaptureTheQueen(int yRook, int xRook, int yBishop, int xBishop, int yQueen, int xQueen) {\n if (xRook == xQueen) {\n // check if the bishop is block the vertical way\n if ((xRook == xBishop) && \n (((yRook < yBishop) &&... |
3,270 | <p>There is a <strong>1-indexed</strong> <code>8 x 8</code> chessboard containing <code>3</code> pieces.</p>
<p>You are given <code>6</code> integers <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, and <code>f</code> where:</p>
<ul>
<li><code>(a, b)</code> denotes the position of the ... | 3 | {
"code": "class Solution {\n void f1(int a,int b,int c,int d,int &mini1,int e,int f){\n \n if(c==a or d==b){\n if(c==a and a==e){\n if((d>f and b>f) or (d<f and b<f)){\n cout<<\"hix\"<<a<<\",\"<<e<<\",\"<<c<<endl; mini1=1;\n }\n ... |
3,270 | <p>There is a <strong>1-indexed</strong> <code>8 x 8</code> chessboard containing <code>3</code> pieces.</p>
<p>You are given <code>6</code> integers <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, and <code>f</code> where:</p>
<ul>
<li><code>(a, b)</code> denotes the position of the ... | 3 | {
"code": "class Solution {\npublic:\n int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {\n /*for the bishop, it can be 1 only. otherwise its a long route, rook is faster.\n for the rook, it can be 1 or 2. check if there is bishop in the way. if so, dont include this way */\n... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n\n ranges::sort(nums1), ranges::sort(nums2);\n \n auto it1 = ranges::unique(nums1);\n nums1.erase(it1.begin(), it1.end());\n auto it2 = ranges::uniq... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\n\n public:\n\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n\n int N = nums1.size();\n\n auto f = [](vector<int>& vs) {\n\n ranges::sort(vs);\n\n vs.erase(unique(vs.begin(), vs.end()), vs.end());\n\n };\n\n f(nums1), f(nums2);\n\n int cnt = 0;\n... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n=nums1.size();\n sort(nums1.begin(),nums1.end());\n sort(nums2.begin(),nums2.end());\n vector<int> ans1;\n vector<int>ans2;\n ans1.push_back(nums1[0]);\n ans2.... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n=nums1.size();\n sort(nums1.begin(),nums1.end());\n sort(nums2.begin(),nums2.end());\n vector<int> ans1;\n vector<int>ans2;\n ans1.push_back(nums1[0]);\n ans2.... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n unordered_map<int,int> temp;\n for (int i = 0; i < n; ++i){\n temp[nums1[i]] |= 1;\n temp[nums2[i]] |= 2;\n }\n int a[4] = {0,0,0,0}... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n unordered_map<int,int> temp;\n for (auto& num : nums1){\n temp[num] |= 1;\n }\n for (auto& num : nums2){\n temp[num] |= 2;\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "#pragma GCC optimize(\"O3,unroll-loops\")\n\nstatic const bool Booster = [](){\n std::ios_base::sync_with_stdio(false);\n std::cout.tie(nullptr);\n std::cin.tie(nullptr);\n return true;\n}();\nclass Solution {\npublic:\n // void pr(set<int> &st){\n // cout<<\"st: \"<<\" [\";\n // ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n std::map<int, int> m;\n for (auto v : nums1)\n m[v] |= (1 << 0);\n for (auto v : nums2)\n m[v] |= (1 << 1);\n int n1 = nums1.size() / 2;\n int n2 = nums2.si... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int m = nums1.size()/2;\n unordered_map<int,int> mp1,mp2;\n \n for(auto &i: nums1){\n mp1[i]++;\n }\n for(auto &i: nums2){\n mp2[i]++;\n }\n int u1 =0, u... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int m = nums1.size()/2;\n unordered_map<int,int> mp1,mp2;\n \n for(auto &i: nums1)\n mp1[i]++;\n\n for(auto &i: nums2)\n mp2[i]++;\n\n int u1 = 0, u2 = 0, cm = 0;\... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int N = nums1.size();\n unordered_map<int,int> mp1;\n unordered_map<int,int> mp2;\n for(auto n : nums1) {\n mp1[n]++;\n }\n for(auto n : nums2) {\n m... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size()/2;\n unordered_map<int , int> mp1, mp2;\n for(auto &i: nums1){\n mp1[i]++;\n }\n for(auto &i: nums2){\n mp2[i]++;\n }\n int... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(std::vector<int>& nums1, std::vector<int>& nums2) {\n int n1 = static_cast<int>(nums1.size() / 2);\n int n2 = n1;\n std::unordered_map<int, std::pair<int, int>> mapCount;\n auto fill = [&mapCount](std::vector<int>& nums, bool fir... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(std::vector<int>& nums1, std::vector<int>& nums2) {\n int n1 = static_cast<int>(nums1.size() / 2);\n int n2 = n1;\n std::unordered_map<int, std::pair<int, int>> mapCount;\n auto fill = [&mapCount](std::vector<int>& nums, bool fir... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(std::vector<int>& nums1, std::vector<int>& nums2) {\n int n1 = static_cast<int>(nums1.size() / 2);\n int n2 = n1;\n std::unordered_map<int, std::pair<int, int>> mapCount;\n auto fill = [&mapCount](std::vector<int>& nums, bool fir... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 0 | {
"code": "class Solution {\npublic:\n int maximumSetSize(std::vector<int>& nums1, std::vector<int>& nums2) {\n int n1 = static_cast<int>(nums1.size() / 2);\n int n2 = n1;\n std::unordered_map<int, std::pair<int, int>> mapCount;\n auto fill = [&mapCount](std::vector<int>& nums, bool fir... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(std::vector<int>& nums1, std::vector<int>& nums2) {\n int n1 = static_cast<int>(nums1.size() / 2);\n int n2 = n1;\n std::unordered_map<int, std::pair<int, int>> mapCount;\n auto fill = [&mapCount](std::vector<int>& nums, bool fir... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(std::vector<int>& nums1, std::vector<int>& nums2) {\n int n1 = static_cast<int>(nums1.size() / 2);\n int n2 = n1;\n std::unordered_map<int, std::pair<int, int>> mapCount;\n auto fill = [&mapCount](std::vector<int>& nums, bool fir... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) \n {\n int x = nums1.size();\n int y = nums2.size();\n\n set<int>st1;\n set<int>st2;\n\n for(auto it:nums1)\n st1.insert(it);\n\n\n for(auto it:nums2)\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> lhs(begin(nums1), end(nums1)),\n rhs(begin(nums2), end(nums2));\n const int n = size(nums1), h = n / 2;\n int dl = n - size(lhs), dr = n - size(rhs);\n for... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& a, vector<int>& b) {\n set<int>m;\n for(int i:a){\n m.insert(i);\n }\n \n int n=a.size();\n int ans=0;\n int sz = m.size();\n \n if(sz<=(n/2)){\n ans=sz;\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n set<int> s1, s2;\n for(auto &num: nums1) s1.insert(num);\n for(auto &num: nums2) s2.insert(num);\n int n = nums1.size(), n1 = s1.size(), n2 = s2.size();\n int sames = 0;\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n set<int> first, second;\n int n = nums1.size() / 2;\n\n for (auto& el : nums1) {\n first.insert(el);\n }\n\n for (auto& el : nums2) {\n second.insert(el);\n... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n=nums1.size();\n set<int> s1(nums1.begin(),nums1.end());\n set<int> s2(nums2.begin(),nums2.end());\n int n12=0;\n for(int i:s1)\n {\n n12+=s2.count(i);\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int m = nums1.size();\n int n = nums2.size();\n set<int>s1(nums1.begin(),nums1.end());\n set<int>s2(nums2.begin(),nums2.end());\n int common = 0;\n auto it = s2.begin();\n... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n set<int> s1;\n set<int> s2;\n for(auto i:nums1) s1.insert(i);\n for(auto i:nums2) s2.insert(i);\n int n = nums1.size() / 2;\n // set<int> st;\n int j = n;//3\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n=nums1.size();\n set<int>s1,s2;\n for(auto i:nums1)\n s1.insert(i);\n for(auto i:nums2)\n s2.insert(i);\n int a=s1.size(),b=s2.size(),c=0;\n for... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n set<int>a,b;\n for(auto x:nums1) a.insert(x);\n for(auto x:nums2) b.insert(x);\n\n int n=nums1.size();\n int diffa= a.size();\n int diffb= b.size();\n\n int common=... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n set <int> s1;\n set <int> s2;\n int n=nums1.size();\n\n for(auto it: nums1){\n s1.insert(it);\n }\n for(auto it: nums2){\n s2.insert(it);\n }\... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n map<int, int> f1, f2;\n for(auto &e:nums1) f1[e]++;\n for(auto &e:nums2) f2[e]++;\n int ans = 0;\n int ct = 0;\n for(auto &[e, v]:f1) {\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> s1, s2, common;\n int n = nums1.size();\n for (auto i : nums1)\n s1.insert(i);\n for (auto i : nums2) {\n s2.insert(i);\n if (s1.find... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n \n unordered_set<int> set1;\n unordered_set<int> set2;\n unordered_set<int> common;\n int originalSize1 = nums1.size();\n \n for( int i=0; i<nums1.size(); ++i)\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> s1, s2, common;\n\n for(int num : nums1) {\n s1.insert(num);\n }\n\n for(int num : nums2) {\n s2.insert(num);\n if(s1.count(num)) {\n... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n \n /*\n first find all unique elements from nums1 and nums2\n */\n int n1 = nums1.size()/2;\n \n unordered_map<int, int> c1;\n for(int num : nums1)\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "// class Solution {\n// public:\n// int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n// // return 0;\n// map<int, int> mp1;\n// for (auto i : nums1) mp1[i]++;\n// map<int, int> mp2;\n// for (auto i : nums2) mp2[i]++;\n \n// int n1 = nu... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n= nums1.size();\n set<int> nums11;\n\n for(int i:nums1) nums11.insert(i);\n\n set<int> nums22;\n\n for(int i: nums2) nums22.insert(i);\n \n \n nums1.clear()... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n set<int>s1(nums1.begin(), nums1.end()), s2(nums2.begin(), nums2.end());\n for(auto it=s1.begin(); it!=s1.end() && s1.size()>n/2;){\n if(s2.find(*it)!=s2.end(... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n \n unordered_set<int>s;\n for(auto it:nums1)\n {\n s.insert(it);\n }\n\n unordered_set<int>s2;\n vector<int>common;\n for(auto it:nums2)\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n int m = nums2.size();\n set<int>st = {nums1.begin(),nums1.end()};\n nums1 = {st.begin(),st.end()};\n st = {nums2.begin(),nums2.end()};\n nums2 = {s... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> s1;\n unordered_set<int> s2;\n int n=nums1.size();\n\n\n for(int i:nums1) s1.insert(i);\n for(int i:nums2) s2.insert(i);\n for(int i:s1) cout<<i<<' ';\n\n int ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> s1;\n unordered_set<int> s2;\n int n=nums1.size();\n\n\n for(int i:nums1) s1.insert(i);\n for(int i:nums2) s2.insert(i);\n int n1=s1.size();\n int n2=s2.size()... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n unordered_map<int,int> b1,b2;\n int n=nums1.size();\n for (int i=0;i<n;i++){\n b1[n... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n unordered_map<int,int> b1,b2;\n int n=nums1.size();\n for (int i=0;i<n;i++){\n b1[n... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n unordered_map<int,int> b1,b2;\n int n=nums1.size();\n for (int i=0;i<n;i++){\n b1[n... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n=nums1.size();\n unordered_set<int>st1,st2;\n for(int i=0;i<n;i++){\n st1.insert(nums1[i]);\n }\n for(int i=0;i<n;i++){\n st2.insert(nums2[i]);\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& n1, vector<int>& n2) {\n unordered_set<int> s1,s2;\n int n=n1.size();\n for(int i=0;i<n1.size();i++) s1.insert(n1[i]);\n for(int i=0;i<n2.size();i++) s2.insert(n2[i]);\n int a1=s1.size(),a2=s2.size();\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size();\n set<int> st1, st2, st;\n for(auto it: nums1) st1.insert(it);\n for(auto it: nums2) st2.insert(it);\n\n for(auto it: nums1){\n if(st2.count(it))... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n set<int>s1;\n set<int>s2;\n set<int>comm;\n int n=nums1.size();\n for(auto i:nums1){\n s1.insert(i);\n }\n for(auto i:nums2){\n s2.insert(i);\... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 1 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n set<int> s1,s2,comm;\n int n=nums1.size();\n \n for(auto it:nums1) s1.insert(it);\n for(auto it:nums2){\n s2.insert(it);\n if(s1.count(it)>0){\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n set<int>st1,st2,st3;\n int n = nums1.size();\n for(int i=0;i<nums1.size();i++){\n st1.insert(nums1[i]);\n }\n int a =st1.size();\n for(int i=0;i<nums2.size();i+... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "#define all(v) v.begin(),v.end()\n\nclass Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n=nums1.size();\n set<int> st1(all(nums1));\n set<int> st2(all(nums2));\n set<int> common;\n for(auto &it:st1)\n {\n if(... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n const int N = nums1.size();\n\n set<int> s1(nums1.begin(), nums1.end());\n set<int> s2(nums2.begin(), nums2.end());\n\n set<int> intersection;\n for(int num: s1){\n if... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n \n unordered_set<int>s;\n for(auto it:nums1)\n {\n s.insert(it);\n }\n\n unordered_set<int>s2;\n unordered_set<int>common;\n for(auto it:nums2)\n ... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "class Solution {\npublic:\n/*\np1->x1->(x1-com,n/2)\np2->x2->(x2-com,n/2)\ncom->x\n*/\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n int n = nums1.size() ;\n int ans = 0 ;\n vector<int>p1,p2 ;\n map<int,int>mp1,mp2 ;\n for(int i = 0 ; i < nums1.size()... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "#define loop(var, start, end) for(int var=start;var<=end;var++)\n#define debug(c) cout<<#c<<\": \"<<c<<endl\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"fast-math\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"no-stack-protector\")\nconst static auto fast = []\n{\n std::i... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "#define loop(var, start, end) for(int var=start;var<=end;var++)\n#define debug(c) cout<<#c<<\": \"<<c<<endl\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"fast-math\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"no-stack-protector\")\nconst static auto fast = []\n{\n std::i... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> s;\n int n1=nums1.size();\n int n2=nums2.size();\n for(int i=0;i<n1;i++){\n s.insert(nums1[i]);\n }\n int use1=s.size();\n s.clear();\... |
3,228 | <p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of even length <code>n</code>.</p>
<p>You must remove <code>n / 2</code> elements from <code>nums1</code> and <code>n / 2</code> elements from <code>nums2</code>. After the removals, you insert the remaining elemen... | 2 | {
"code": "class Solution {\npublic:\n int maximumSetSize(vector<int>& nums1, vector<int>& nums2) {\n unordered_set<int> s;\n int n = nums1.size();\n for(int i=0;i<n;i++){\n s.insert(nums1[i]);\n }\n int use1=s.size();\n s.clear();\n for(int i=0;i<n;i++){\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.