id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
0
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int min_len = INT_MAX, cnt = 0;\n int len[26];\n for (int i = 0; i < 26; i++)\n len[i] = INT_MAX;\n for (int i = 0; i < points.size(); i++) {\n int tmp = max...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
0
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int n = points.size();\n vector<vector<int>> a(26, vector<int>(2, INT_MAX));\n for (int i=0; i<n; i++) {\n int tag = s[i] - 'a';\n int curr = max(abs(points[i][0]),...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
0
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<vector<int>> tags(26, vector<int>(2, -1));\n int minLen = INT_MAX;\n \n for(int i=0; i<points.size(); i++){\n if(tags[s[i]-'a'][0] == -1 && tags[s[i]-'a'][1] == ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
0
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int n = points.size();\n auto chk = [&](int len) -> int {\n vector<int> tag(26, 0);\n int res = 0;\n for(int i = 0; i < points.size(); ++i) {\n a...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
0
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<int> sq;\n for(int i = 0; i < points.size(); i++)\n {\n sq.push_back(max(abs(points[i][0]) , abs(points[i][1])));\n }\n map<char , int> mp;\n int b...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
1
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& a, string s) {\n vector<int> zx[26];\n int i, l, ky = 2000000000, res = 0;\n for (i = 0; i < a.size(); ++i){\n l = max(labs(a[i][0]), labs(a[i][1]));\n zx[s[i] - 'a'].push_back(l);\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
1
{ "code": "class Solution {\npublic:\n int distance (int x1, int x2){\n int a = sqrt(pow(x2-x1 , 2));\n return a; \n }\n\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n unordered_map <char, vector<int>> mp; \n int boxsize = INT_MAX; \n\n for(int i =0;...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
1
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n unordered_map<char,vector<int>>map;\n for(int i=0;i<s.length();i++){\n map[s[i]].push_back(max(abs(points[i][0]),abs(points[i][1])));\n }\n int val=INT_MAX;\n fo...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
1
{ "code": "class Solution {\npublic:\n int canInside(int len, vector<pair<int, char>>& pnts){\n bool tags[26] = {false};\n int cnt = 0;\n\n for(int i = 0; i < pnts.size() && pnts[i].first <= len; i++){\n if(tags[pnts[i].second - 'a'])\n return -1;\n \n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
1
{ "code": "class Solution {\npublic:\n int canInside(int len, vector<pair<int, char>>& pnts){\n int tags[26] = {0};\n int cnt = 0;\n\n for(int i = 0; i < pnts.size() && pnts[i].first <= len; i++){\n if(tags[pnts[i].second - 'a'] > 0)\n return -1;\n \n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
1
{ "code": "class Solution {\npublic:\n int canInside(int len, vector<pair<int, char>>& pnts){\n int tags[26] = {0};\n int cnt = 0;\n\n for(int i = 0; i < pnts.size() && pnts[i].first <= len; i++){\n if(tags[pnts[i].second - 'a'] > 0)\n return -1;\n \n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n\n bool isInside(int x, int y, int len){ // len = always even\n int lo = -(len/2), hi = (len/2);\n if(x<lo || x>hi){return 0;}\n if(y<lo || y>hi){return 0;}\n return 1;\n } \n\n // It is possible to make a Valid Square of side length = len ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\n\n\npair<int,bool> possible(int mid, vector<vector<int>>&p, string s){\n int cnt = 0;\n bool noval = true;\n set<char>put;\n \n\n for(int i = 0; i<p.size(); i++){\n if(abs(p[i][0]) <= mid && abs(p[i][1]) <= mid){\n noval = false;\n if(put.find(s...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\n #define ll long long int\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& p, string s) {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n vector<pair<ll,char>>v;\n for(int i=0;i<p.size();i++){\n v.push_back({(1ll*max(abs(p[i][0]),ab...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\n #define ll long long int\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& p, string s) {\n vector<pair<ll,char>>v;\n for(int i=0;i<p.size();i++){\n v.push_back({(1ll*max(abs(p[i][0]),abs(p[i][1]))*(max(abs(p[i][0]),abs(p[i][1])))),s[i]});\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<int> tagLengths(26, INT_MAX);\n int minLen = INT_MAX;\n\n for (int i=0; i<points.size(); i++) {\n auto vec = points[i];\n int x = vec[0], y = vec[1];\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n bool isValid(vector<vector<int>>& points, string s, int len){\n vector<int>dict(26, 0);\n for(int i=0;i<points.size();i++){\n if(points[i][0]<=len && points[i][1]<=len){\n dict[s[i]-'a']++;\n }\n }\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n static bool comp(const vector<int>& a, const vector<int>& b) \n {\n return max(abs(a[0]), abs(a[1])) < max(abs(b[0]), abs(b[1]));\n }\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n for(int i=0;i<points.size();i++)\n po...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n for(int i = 0; i<points.size(); i++){\n points[i][0] = abs(points[i][0]);\n points[i][1] = abs(points[i][1]);\n sort(points[i].rbegin(), points[i].rend());\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "#define ll long long\nclass Solution {\n int res = 0;\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n ll left = 0, right = 1e10;\n int res = -1;\n while(left <= right)\n {\n ll mid = left + (right - left) / 2;\n int cnt...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n bool isPossible(int mid,vector<vector<int>>& points,string s){\n\n unordered_map<char,int> mp;\n for(int i=0; i<points.size(); i++){\n if(abs(points[i][0]) <= mid && abs(points[i][1]) <= mid){\n \n if(mp.find(s[i]) != mp....
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n vector<int> corrSquare(vector<vector<int>>&points){\n vector<int> ans;\n for(auto point:points){\n int maxi=max(abs(point[0]),abs(point[1]));\n ans.push_back(maxi);\n }\n return ans;\n }\n int maxPointsInsideSquare(vecto...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\nbool check(vector<vector<int>>&points,string s,int mid)\n{\n unordered_map<char,int>mp;\n int n=points.size();\n for(int i=0;i<n;i++)\n {\n int row=points[i][0];\n int col=points[i][1];\n if(abs(row)<=mid&&abs(col)<=mid)\n mp[s[i]]++;\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\nbool isPossible(vector<vector<int>>& points, string s,long long mid,int &count)\n{\n unordered_set<char>set;\n int c=0;\n for(int i=0;i<points.size();i++)\n {\n if(2*abs(points[i][0])<mid && 2*abs(points[i][1])<mid)\n {\n if(set.find(s[i])!=se...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int func(vector<vector<int>>& points,int lim,string s){\n int l=points.size();\n set<char>st;\n int ans=0;\n for(int i=0;i<l;i++){\n char ch=s[i];\n int a=abs(points[i][0]);\n int b=abs(points[i][1]);\n i...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n unordered_map<char,vector<int>> mp;\n int i=0;\n for(auto it:points){\n int maxi = max(abs(it[0]),abs(it[1]));\n mp[s[i]].push_back(maxi);\n i++;\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n if (points.size() == 1)\n return 1;\n \n int n = points.size();\n int ans = 0;\n vector<int> count(26, 0);\n vector<vector<int>> new_points(n, vector<int>...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n \n vector<vector<int>> point_tag(s.size());\n for (int i=0; i<s.size(); i++) {\n point_tag[i] = {points[i][0], points[i][1], s[i]-'a'};\n }\n\n std::sort(point_ta...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "#include<bits/stdc++.h>\n\nclass Solution {\npublic:\n bool does_this_point_lie_inside(int edge_size,vector<int> &point){\n int x=point[0];\n int y=point[1];\n\n if(x<(-1*(edge_size)) || y<(-1*(edge_size)) || x>edge_size || y>edge_size){\n return false;\n }\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<multiset<int>> v(26);\n int n=s.size();\n for(int i=0;i<n;i++){\n v[s[i]-'a'].insert(max(abs(points[i][0]),abs(points[i][1])));\n }\n int mini=INT_MAX;\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<int>a(26,1e9+10);int n=s.size();int ans=1e9+10;\n for(int i=0;i<n;i++){\n auto c=points[i];\n auto str=s[i];\n int prev=a[str-'a'],cur=max(abs(c[0]),abs(...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "#include <bits/stdc++.h>\n#include <ext/pb_ds/assoc_container.hpp>\nusing namespace __gnu_pbds;\nusing namespace std;\nusing ll=long long;\ntypedef tree <pair<ll,ll>, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n/*\n order_of_key (k)\n find_by_order(k)\n*/\ntemplat...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int,string>m;\n for(int i=0;i<points.size();i++){\n int x=abs(points[i][0]);\n int y=abs(points[i][1]);\n int range=max(x,y);\n m[range]+=s[i];\n...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int n=s.size();\n int ans = 0;\n map<int,string>m;\n for(int i=0;i<n;i++){\n int x = abs(points[i][0]);\n int y = abs(points[i][1]);\n m[max(x,y)]...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n \n int maxPointsInsideSquare(vector<vector<int>>& points, string s) \n {\n vector<vector<int>> dots;\n for(int i=0; i<points.size(); i++)\n {\n int dist=max(abs(points[i][0]),abs(points[i][1]));\n dots.push_back({dist, s[i]-'a'...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n \n int maxPointsInsideSquare(vector<vector<int>>& points, string s) \n {\n /*\n [[16,32,a],[27,3,a],[23,-14,a],[-32,-16,b],[-3,26,f],[-14,33,c]]\n [[23,-14,a],[-3,26,f],[27,3,a],[16,32,a],[-32,-16,b],[-14,33,c]]\n\n\n\n */\n vector<vec...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "bool mycmp(vector<int>&a,vector<int> &b){\n return max(abs(a[0]),abs(a[1]))<max(abs(b[0]),abs(b[1]));\n}\nclass Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<vector<int>> v;\n for(int i=0;i<points.size();i++){\n v.push_back(...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "bool mycmp(vector<int>&a,vector<int> &b){\n return max(abs(a[0]),abs(a[1]))<max(abs(b[0]),abs(b[1]));\n}\nclass Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<vector<int>> v;\n for(int i=0;i<points.size();i++){\n v.push_back(...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "#include<algorithm>\nclass Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int n=s.size();int cnt=0;int maxi=-1;\n map<int ,vector<char>>mpp;\n for(int i=0;i<n;i++)\n {\n maxi=max(abs(points[i][0]),abs(points[i][1]));\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int n = points.size();\n map<int,vector<char>>mp;\n for(int i=0;i<n;i++)\n {\n int x = abs(points[i][0]);\n int y = abs(points[i][1]);\n int maxi = max(x,y);\n mp[maxi...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
2
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int,vector<char>> mp;\n for(int i=0;i<points.size();i++){\n mp[max(abs(points[i][0]),abs(points[i][1]))].push_back(s[i]);\n }\n int ans=0;\n int freq[26]={0...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int,vector<char>> mp;\n int n = points.size();\n for(int i=0; i<n; i++){\n int d = max(abs(points[i][0]), abs(points[i][1]));\n mp[d].push_back(s[i]);\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n for(auto &t:points){\n t[0]=abs(t[0]);\n t[1]=abs(t[1]);\n }\n int ans=0;\n map<int,vector<char>>mp;\n for(int i=0;i<points.size();i++){\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "#include <bits/stdc++.h>\nusing namespace std;\n\nclass Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n set<int> st;\n int n = points.size();\n vector<unordered_map<int,int>> temparr(26);\n for (int i = 0; i < n; i++)\n {\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n // bool fun(int l, int h,vector<vector<int>>& points, string &s, int cnt){\n\n // }\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int, vector<char>> mp;\n int n = points.size();\n set<char> st;\n vector<pair<int, ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<pair<int,char>>v;\n\n for(int i=0;i<points.size();i++){\n v.push_back({max(abs(points[i][0]),abs(points[i][1])),s[i]});\n }\n \n map<int,vector<char>>mp;\...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n // Check function to determine if all points with max(abs(x), abs(y)) <= mid have unique characters\n bool check(vector<pair<vector<int>, char>>& p, int mid) {\n vector<int> c(26, 0);\n for (auto it : p) {\n if (max(abs(it.first[0]), abs(it.first[1...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n unordered_map<string, int> indexes;\n for (int i = 0; i < points.size(); ++i) {\n indexes[pointToStr(points[i])] = i;\n }\n\n sort(points.begin(), points.end(), [](vect...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int ans=0;\n map<int,vector<char>>mp;\n int i=0;\n for(auto ed:points)\n {\n mp[max(abs(ed[0]),abs(ed[1]))].push_back(s[i]);\n i++;\n }\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int n=points.size();\n map<int, vector<char>> mpp;\n set<char> st;\n int count=0;\n int i=0;\n int dist;\n \n for(auto it:points){\n int val...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int,vector<char>> mp;\n \n int i = 0 , ans = 0 ;\n for(auto it : points)\n {\n int x = abs(it[0]);\n int y = abs(it[1]);\n \n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n\n vector<int>v;\n for(auto it: points)\n v.push_back(max(abs(it[0]) , abs(it[1])));\n\n map<int, vector<char>>m;\n for(int i=0; i<s.size(); i++)\n m[v[i]].push...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int findMin(vector<vector<int>>&points)\n {\n int gMin = INT_MAX;\n int sgMin = INT_MAX-1;\n for(int i=0;i<points.size();i++)\n {\n int sqLen = max(abs(points[i][0]),abs(points[i][1]));\n if(sqLen<=gMin)\n \n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int findMin(vector<vector<int>>&points)\n {\n int gMin = INT_MAX;\n int sgMin = INT_MAX-1;\n for(int i=0;i<points.size();i++)\n {\n int sqLen = max(abs(points[i][0]),abs(points[i][1]));\n if(sqLen<=gMin)\n \n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n \n map<int,map<int,int>> mp ; \n\n for(int i = 0 ; i < (int)s.size() ; i++) \n {\n int x = points[i][0], y = points[i][1] ; \n mp[max(abs(x),abs(y))][s[i] - ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string str) {\n int ans = 0;\n\n map<int,set<int>>mp;\n for(int i = 0;i < points.size();i++){\n mp[max(abs(points[i][0]),abs(points[i][1]))].insert(i);\n }\n vector<int>cnt(26...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int,multiset<char>> mp;\n \n set<char> s1;\n for(int i=0;i<points.size();i++){\n mp[max(abs(points[i][0]),abs(points[i][1]))].insert(s[i]);\n }\n int ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int,multiset<char>> mp;\n int ans=0;\n for(int i=0;i<points.size();i++){\n mp[max(abs(points[i][0]),abs(points[i][1]))].insert(s[i]);\n }\n set<char> st;\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n unordered_map<int , unordered_map<int, char> > m;\n for(int i = 0; i<s.size(); ++i)\n {\n m[points[i][0]][points[i][1]] = s[i];\n }\n auto cmp = [](const vector<...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int, vector<int>> mp; // Map to store distance -> frequency of characters\n for (int i = 0; i < points.size(); i++) {\n int u = abs(points[i][0]);\n int v = abs(points...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\ntypedef long long ll;\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n vector<pair<long long,char>>a;\n int n=s.size();\n map<int,multiset<char>>mp;\n for(int i=0;i<n;i++)\n {\n long long d= max(abs(points[i][...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n unordered_map<char,multiset<int>>m;\n for(int i=0;i<points.size();i++)\n {\n int x=abs(points[i][0]),y=abs(points[i][1]);\n int d=max(x,y);\n m[s[i]].ins...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int,multiset<char>> mp;\n // vector<pair<int,int>> chk;\n // string ll;\n int ans=0;\n for(int i=0;i<points.size();i++){\n mp[max(abs(points[i][0]),abs(point...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n bool legit(int square, map<char,vector<pair<int,int>>> &m, int &count) {\n int xmax=square;\n int ymax=square;\n int ymin=-square;\n int xmin=-square;\n for(auto a: m) {\n auto s = a.second;\n int c=0;\n for(...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n bool legit(int square, map<char,vector<pair<int,int>>> &m, int &count) {\n int xmax=square;\n int ymax=square;\n int ymin=-square;\n int xmin=-square;\n for(auto a: m) {\n auto s = a.second;\n int c=0;\n for(...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int n = points.size();\n std::map<int, std::unordered_map<char, int>> count;\n for (int i = 0; i < n; i++) {\n auto& p = points[i];\n int max = std::max(abs(p[0]), ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n \n map<int,unordered_set<char>> sq_len_map;\n\n for(int i=0;i<points.size();i++)\n {\n int x = points[i][0];\n int y = points[i][1];\n char tag = ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int ans = 0;\n map<int, unordered_multiset<char>> m;\n unordered_set<char> seen;\n \n for (int i = 0; i < size(s); i++) {\n m[max(abs(points[i].front()), abs(poi...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n unordered_map<int, unordered_set<char>> ptstag;\n int top = INT_MAX;\n \n for (int i = 0; i < points.size(); i++) {\n int x = points[i][0];\n int y = points[...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n int n = points.size();\n vector<array<int, 2>> tup;\n for(int i = 0; i < n; i++) {\n tup.push_back({max(abs(points[i][0]), abs(points[i][1])), i});\n }\n sort(tu...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& a, string s) \n {\n int n=a.size();\n map<int,unordered_map<char,int>>m;\n for(int i=0;i<n;i++)\n {\n vector<int>x=a[i];\n int val=max(abs(x[0]),abs(x[1]));\n\n m[va...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n map<int, unordered_set<char>> mp;\n int index = 0, maxHalfLen = INT_MAX;\n for(auto point : points) {\n int halfLen = max(abs(point[0]), abs(point[1]));\n if(mp[hal...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n bool help(vector<vector<int>>& points,int mid, map<char,vector<pair<int,int>>> mp,string s){\n for(int i=0;i<s.length();i++){\n if(abs(points[i][0])<=mid && abs(points[i][1])<=mid){\n mp[s[i]].push_back({points[i][0],points[i][1]});\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n bool help(vector<vector<int>>& points,int mid, map<char,vector<pair<int,int>>> mp,string s){\n for(int i=0;i<s.length();i++){\n if(abs(points[i][0])<=mid && abs(points[i][1])<=mid){\n mp[s[i]].push_back({points[i][0],points[i][1]});\n ...
3,419
<p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p> <p>A <strong>valid</strong> square is a square centered a...
3
{ "code": "class Solution {\npublic:\n int maxPointsInsideSquare(vector<vector<int>>& points, string s) {\n // Storing mapping of point and its tag\n map<vector<int>, char> tag_mapping;\n for (int i = 0; i < points.size(); i++) {\n tag_mapping[points[i]] = s[i];\n }\n\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
0
{ "code": "class Solution {\npublic:\n bool contains(vector<int>&arr, int value) {\n for (auto num:arr) {\n if (num == value)\n return true;\n }\n return false;\n }\n\n int missingInteger(vector<int>& arr) {\n int pss = arr[0];\n for (int i = 1; i ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
0
{ "code": "class Solution {\npublic:\nbool check(vector<int>&nums , int num){\n for(auto a: nums){\n if(a==num){\n return true;\n }\n }\n return false;\n}\n int missingInteger(vector<int>& nums) {\n //find sum of all intergers(numbers) until given condition is satisfied\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
0
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int sum = nums[0];\n int n = nums.size();\n int i = 1;\n while (i < n && nums[i] == nums[i-1] + 1) {\n sum += nums[i];\n i++;\n }\n std::sort(nums.begin(), nums.end());\n...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
0
{ "code": "class Solution {\npublic:\n bool contains(vector<int>&arr, int value) {\n for (auto num:arr) {\n if (num == value)\n return true;\n }\n return false;\n }\n\n int missingInteger(vector<int>& arr) {\n int pss = arr[0];\n for (int i = 1; i ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
0
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int n = nums.size();\n int prefixSum = 0;\n for (int i = 0; i < n; ++i) {\n if (i == 0 || nums[i] == nums[i - 1] + 1) {\n prefixSum += nums[i];\n } else {\n brea...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
1
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int sum = nums[0];\n int n = nums.size();\n int i = 1;\n while (i < n && nums[i] == nums[i-1] + 1) {\n sum += nums[i];\n i++;\n }\n std::sort(nums.begin() + i, nums.end()...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
1
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int prefixSum = nums[0];\n for(int i = 1; i < nums.size(); i++) {\n if(nums[i-1] + 1 == nums[i]) {\n prefixSum += nums[i];\n }\n else {\n break;\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
1
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int s{nums[0]};\n for (int i = 1; i < nums.size(); i++)\n {\n if (nums[i] != nums[i - 1] + 1)\n {\n break;\n }\n else\n {\n s +=...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
1
{ "code": "class Solution \n{\npublic:\n bool check(vector<int>nums, int i)\n {\n for(auto j : nums)\n {\n if(j == i)\n return true;\n }\n return false;\n }\n \n int missingInteger(vector<int>& nums) \n {\n int sum = nums[0];\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int n=nums.size(),indx=0,flag=1;\n vector<int> v(n,0);\n v[0]=nums[0];\n for(int i=1;i<n;i++){\n if(flag==1 && nums[i]==nums[i-1]+1){\n indx = i;\n }\n else f...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n if(nums.size()==1)\n return nums[0]+1;\n set<int>set;\n int sum=nums[0];\n set.insert(nums[0]);\n int i=1;\n while(i<nums.size() && nums[i-1]+1==nums[i]){\n set.insert(nums[i...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int n=nums.size();\n set<int>s1(nums.begin(),nums.end());\n int i=0;\n int sum=0;\n for(i=0;i<n;i++){\n if(i>0 && nums[i]!=nums[i-1]+1){\n break; \n }\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n set<int>st;\n int n = nums.size();\n for(int i = 0; i<n;i++)\n {\n st.insert(nums[i]);\n }\n int ind = 0;\n int sum = 0;\n sum += nums[ind];\n for(int i = 1; i<...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int n = nums.size(), x = nums[0] + 1, i = 1, sum = nums[0];\n unordered_map<int, bool>mmap;\n mmap[nums[0]] = true;\n\n while(i < n && nums[i] == x) {\n sum += nums[i++];\n x++;\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int n = nums.size(), x = nums[0] + 1, i = 1, sum = nums[0];\n unordered_map<int, bool>mmap;\n mmap[nums[0]] = true;\n\n while(i < n && nums[i] == x) {\n // mmap[nums[i]] = true;\n sum ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int n = nums.size(), x = nums[0] + 1, i = 1, sum = nums[0];\n unordered_map<int, bool>mmap;\n mmap[nums[0]] = true;\n\n while(i < n && nums[i] == x) {\n sum += nums[i++];\n x++;\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int prev = nums[0];\n int sum = prev;\n\n for (int i = 1; i < nums.size(); i++) {\n if (nums[i] == prev + 1) {\n sum += nums[i];\n prev = nums[i];\n } else {\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int sum = nums[0];\n for(int i=1; i<nums.size(); i++)\n {\n if(nums[i-1] + 1 == nums[i])\n sum += nums[i];\n else\n break;\n }\n\n unordered_set<in...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int sum=nums[0];\n int n=nums.size();\n unordered_set<int> s;\n for(auto el: nums) s.insert(el);\n\n for(int i=1;i<n;i++){\n if(nums[i]==nums[i-1]+1){\n sum+=nums[i];\n ...
3,236
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code>.</p> <p>A prefix <code>nums[0..i]</code> is <strong>sequential</strong> if, for all <code>1 &lt;= j &lt;= i</code>, <code>nums[j] = nums[j - 1] + 1</code>. In particular, the prefix consisting only of <code>nums[0]</code> is <strong>sequ...
2
{ "code": "class Solution {\npublic:\n int missingInteger(vector<int>& nums) {\n int sum = nums[0];\n for(int i=1; i<nums.size(); i++)\n {\n if(nums[i-1] + 1 == nums[i])\n sum += nums[i];\n else\n break;\n }\n\n unordered_set<in...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
0
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n // if we are <= y, then we have to add\n if (x <= y) return y - x;\n // default answer is just subtract 1 until we get there\n int ans = x - y;\n // if we have to do something else, need to ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
0
{ "code": "class Solution {\npublic:\n int recur(int x, int y){\n if(x <= y) return y - x;\n\n int ans = abs(x - y);\n ans = min(ans, 1 + x % 11 + recur(x / 11, y));\n ans = min(ans, 1 + 11 - x % 11 + recur(x / 11 + 1, y));\n ans = min(ans, 1 + x % 5 + recur(x / 5, y));\n ...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
0
{ "code": "class Solution {\npublic:\n int minimumOperationsToMakeEqual(int x, int y) {\n if(y >=x) return y-x;\n else{\n vector<int> dp(x+20, INT_MAX-1);\n for(int i = 0; i <= x+11; i++){\n if(y>=i) dp[i] = y - i;\n else{\n int a...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
0
{ "code": "class Solution {\nprivate:\n int solve(int x,int y, vector<int>& dp){\n if(y>= x){\n return y-x;\n }\n if(dp[x] != -1){\n return dp[x];\n }\n int result = x-y;\n for(int i = 0;i<=4;i++){\n if((x+i)%5 == 0){\n resul...
3,239
<p>You are given two positive integers <code>x</code> and <code>y</code>.</p> <p>In one operation, you can do one of the four following operations:</p> <ol> <li>Divide <code>x</code> by <code>11</code> if <code>x</code> is a multiple of <code>11</code>.</li> <li>Divide <code>x</code> by <code>5</code> if <code>x</c...
0
{ "code": "class Solution {\npublic:\n int solve(int x, int y,vector<int>&dp) {\n if (x == y) {\n return 0;\n }\n if (y>x) {\n return y-x;\n }\n if(dp[x]!=-1){\n return dp[x];\n }\n \n int ans1 = INT_MAX;\n int ans2 = IN...