id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 1 | {
"code": "class Solution {\n \n void insert(vector<int> &v1,int s,int e,int ind,int val)\n {\n if(s == e)\n {\n v1[ind]+=1;\n return;\n }\n // cout<<\"s is \"<<s<<\" \"<<e<<\" \"<<val<<endl;\n int mid = (s + e)>>1;\n if(val > mid)\n i... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 1 | {
"code": "class Solution {\n \n void insert(vector<int> &v1,int s,int e,int ind,int val)\n {\n if(s == e)\n {\n v1[ind]+=1;\n return;\n }\n // cout<<\"s is \"<<s<<\" \"<<e<<\" \"<<val<<endl;\n int mid = (s + e)>>1;\n if(val > mid)\n i... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 1 | {
"code": "class Node \n{ \npublic: \n int key; \n int count=1;\n Node *left; \n Node *right; \n int height; \n int leftCount; // New: Count of nodes in the left subtree\n int rightCount; // New: Count of nodes in the right subtree\n}; \n \nclass Solution {\npublic:\n\n int heigh... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 1 | {
"code": "class FenwickTree {\n public:\n FenwickTree(int n) : sums(n + 1) {}\n\n void add(int i, int delta) {\n while (i < sums.size()) {\n sums[i] += delta;\n i += lowbit(i);\n }\n }\n\n int get(int i) const {\n int sum = 0;\n while (i > 0) {\n sum += sums[i];\n i -= lowbit(i);\... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 1 | {
"code": "class FenwickTree {\n public:\n FenwickTree(int n) : sums(n + 1) {}\n\n void add(int i, int delta) {\n while (i < sums.size()) {\n sums[i] += delta;\n i += lowbit(i);\n }\n }\n\n int get(int i) const {\n int sum = 0;\n while (i > 0) {\n sum += sums[i];\n i -= lowbit(i);\... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n\n#define LSO(n) ((n) & (-(n)))\n\nclass FT {\npublic:\n vector<int> ft;\n int size;\n\n FT(int sz) {\n size = sz + 1;\n ft.assign(size, 0);\n }\n\n void update(int i, int value) {\n for (; i < size; i += LSO(i)) ft.at(i) +... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "// CREATING THE BINARY INDEX TREE;\n const int N=1e5+7;\n vector<int> bit1(N,0);\n vector<int> bit2(N,0);\n\nclass Solution {\n // NORMALISING THE VECTOR;\n void normaliser(vector<int>& v1, map<int,int>& extra){\n map<int,int> mp;\n for(int i=0; i<v1.size(); i++) mp[v1[i]]=1;\n int ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class Solution {\npublic:\n map<int, int>mp;\n int bit1[100005], bit2[100005];\n int n;\n\n void update(int index, int x, int num){\n for(;index<n;index+=(index&-index)){\n if(num == 1)\n bit1[index]+=x;\n else\n bit2[index]+=x;\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class Solution {\npublic:\n map<int, int>mp;\n int bit1[100005], bit2[100005];\n int n;\n\n void update(int index, int x, int num){\n for(;index<n;index+=(index&-index)){\n if(num == 1)\n bit1[index]+=x;\n else\n bit2[index]+=x;\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class BIT{\npublic:\n int sz;\n vector<int> val;\n BIT(int n) {\n sz = n;\n val = vector<int>(n+1,0);\n }\n int get(int x){\n int result = 0;\n while(x > 0) {\n result += val[x];\n x = x - (x & (-x));\n }\n return result;\n }... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class Solution {\npublic:\n int n;\n void add(vector<int>&bit, int idx){\n while(idx<=n){\n bit[idx]+=1;\n idx += (idx & -idx);\n }\n }\n\n int query(vector<int>&bit, int idx){\n int ans=0;\n while(idx>0){\n ans+=bit[idx];\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "struct node{\n int cnt = 0;\n};\nclass Solution {\n public:\n static const int N = 4*(1e5+1);\n node t[N],p[N];\n node merge(node a,node b){\n node p;\n p.cnt = a.cnt+b.cnt;\n return p;\n }\n void update(int l,int r,int ind,int pos,int f){\n if(pos < l || pos... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class SegmentTree{\n\tint n;\n\tvector<int> ST;\n\t\n\tint query(int sl,int sr,int l,int r,int si){\n\t\tif(l <= sl && sr <= r)return ST[si];\n\t\tif(r < sl || sr < l)return 0;\n\t\tint mid=sl+(sr-sl)/2;\n\t\treturn query(sl,mid,l,r,2*si+1)+query(mid+1,sr,l,r,2*si+2);\n\t}\n\t\n\tvoid update(int sl,int sr,... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class FT {\npublic:\n vector<int> bit;\n FT(int n) {\n bit.resize(n + 1, 0);\n }\n void update(int i, int val) {\n while(i < bit.size()) {\n bit[i] += val;\n i += i & -i;\n }\n }\n int query(int i) {\n int sum = 0;\n while(i > 0) {\... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class segmentTree{\n public:\n vector<int>seg;\n segmentTree(int n){\n seg.resize(4*n+1,0);\n }\n\n void update(int ind, int i,int low, int high){\n if(low==high){\n seg[ind]++;\n return;\n }\n int mid = low+(high-low)/2;\n if(i<=mid) ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class SegmentTree{\n int n;\n vector<int> ST;\n int query(int sl, int sr, int l, int r,int si){\n if(sl > r || sr < l) return 0;\n if(sl >= l && sr <= r) return ST[si];\n int mid=sl+(sr-sl)/2;\n int left_sum=query(sl,mid,l,r,2*si+1);\n int right_sum=query(mid+1,s... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class SegmentTree{\n public:\n int n ;\n vector<int>seg;\n\n SegmentTree(int n){\n this->n = n;\n seg.resize(4*n,0);\n }\n\n int query(int ind, int low, int high, int l, int r){\n //low high l r low high\n if(high < l || low > r)return 0;\n if(low>=l && ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "class SegmentTree{\n int n;\n vector<int> Seg;\n int query(int i, int sL, int sR, int qL, int qR){\n if(sL > qR || sR < qL) return 0;\n if(sL >= qL && sR <= qR) return Seg[i];\n\n int left_sum = query(2 * i + 1, sL, (sL + sR) / 2, qL, qR);\n int right_sum = query(2 * i ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "int modify(vector<int>&nums,int &n,map<int,int>&mp1){\n map<int,int>mp; \n vector<int>u = nums;\n sort(nums.begin(),nums.end());\n int ptr=0;\n for(int i=0;i<n;i++){\n if(mp.find(nums[i])==mp.end()){\n mp[nums[i]] = ptr++;\n mp1[ptr-1] = nums[i];\n }\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n\nclass Solution {\npublic:\n // order_of_key (k) : number of items strictly smaller than k.\n // find_by_order(k) : K-th element in a set (counting from zero).\n\n // note this is not the ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "#include<bits/stdc++.h>\n#include<ext/pb_ds/assoc_container.hpp>\n#include<ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\nusing namespace std;\ntemplate <typename T>\nusing ordered_set = tree<T, null_type, greater_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;\n\nclass Solution {\npub... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "#include<ext/pb_ds/assoc_container.hpp>\n#include<ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n\ntypedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;\n\nclass Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {\n int n =... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "#include<ext/pb_ds/assoc_container.hpp>\n#include<ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n\ntypedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;\n\nclass Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {\n int n =... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "\n#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n\ntypedef tree < int , null_type , less_equal<int> , rb_tree_tag , tree_order_statistics_node_update > order_set;\n\nclass Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "#include <ext/pb_ds/assoc_container.hpp> // Common file\nusing namespace __gnu_pbds;\n\ntypedef tree<\npair<int,int>,\nnull_type,\nless<pair<int,int>>,\nrb_tree_tag,\ntree_order_statistics_node_update>\nordered_set;\n\nclass Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {\n ord... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "#include<ext/pb_ds/assoc_container.hpp>\n#include<ext/pb_ds/tree_policy.hpp>\n\nusing namespace __gnu_pbds;\ntypedef tree<int,null_type, greater_equal<int>,rb_tree_tag, tree_order_statistics_node_update> pbds;\n\nclass Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {\n vector<in... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 2 | {
"code": "#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\ntypedef tree<int, null_type, greater_equal<int>, rb_tree_tag,\n tree_order_statistics_node_update>\n oset;\n\nclass Solution {\npublic:\n vector<int> resultArray(vector<int>& nums)... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <ext/pb_ds/assoc_container.hpp> \n#include <ext/pb_ds/tree_policy.hpp> \nusing namespace __gnu_pbds; \n#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>\nclass Solution {\npublic:\n #define pb push_back\n\n int solve(ordered_multis... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\ntypedef tree<int, null_type, greater_equal<int>, rb_tree_tag,\n tree_order_statistics_node_update>\n oset;\nclass Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\nclass Solution {\npublic:\n#define ordered_set \\\n tree<int, null_type, less_equal<int>, rb_tree_tag, \\\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n //defining template when all elements are distinct \ntemplate <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;\n //defining template when duplicate... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include<bits/stdc++.h>\n#define ll long long\nusing namespace std;\n#include <ext/pb_ds/assoc_container.hpp>\n// Including tree_order_statistics_node_update\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n#define ll long long\ntemplate<class T> using pbds=tree<ll, null_type,less_equal<... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <bits/stdc++.h>\n#define sz size()\n#define bk back()\n#define fi first\n#define se second\n\nusing namespace std;\ntypedef long long ll;\ntypedef pair<int, int> pii;\n\nstruct SegmentTree {\n vector<int> tree;\n\n SegmentTree(int n) { tree.resize(4 * n); }\n\n int sum(int idx, int s, int... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "const int sz=1e5+5;\n#define pb push_back\n#define ll long long\nclass Solution {\npublic:\n\n int t[sz];\n int v[sz];\n int treev[4*sz+4];\n int treet[4*sz+4];\n\n void build1(int low,int high,int tidx){\n if(low==high){\n treet[tidx]=t[low];\n return ;\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<int,int> M;\n int st = 0;\n vector<int> N;\n int n;\n vector<int> HA;\n vector<int> HB;\n vector<int> T1, T2;\n\n void build1(int node, int lef, int rig){\n if(lef == rig){\n T1[node] = HA[lef];\n return;\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "class Node{\n public:\n Node* left ;\n Node* right ;\n int s ;\n int e ;\n int val ;\n Node(int ss , int ee){\n s = ss ;\n e = ee ;\n val = 0 ;\n left = NULL ;\n right = NULL ;\n }\n};\n\nclass SegmentTree{\n public:\n Node* root ;\n\n Seg... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <ext/pb_ds/assoc_container.hpp>\nusing namespace __gnu_pbds;\n\ntypedef pair<int, int> node;\ntypedef tree<node, null_type, less<node>,\n rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n\n\nclass Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n\ntemplate <typename T>\nusing ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;\n\ntemplate <typename T, typename R>\nusing ordered_map = tree<T, R, less<T>... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "class segtree {\npublic:\n int n;\n vector<int> tree;\n segtree(int n) {\n this->n = n;\n tree.resize(4 * n);\n }\n void update(int node, int low, int high, int val) {\n if (low == high) {\n tree[node]++;\n return;\n }\n int mid = (low... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include<ext/pb_ds/assoc_container.hpp>\n#include<ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\ntemplate<typename T>\nusing ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;\n\n\nclass Solution {\npublic:\n ordered_multiset<int> a1,a2;\n ... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <ext/pb_ds/assoc_container.hpp> \n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n//ye multiset vala ordered_set hai , normal set ke liye kess_equal to equal kr dena\n#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>\n\nclass... |
3,350 | <p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p>
<p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c... | 3 | {
"code": "#include <bits/stdtr1c++.h>\n#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace std;\nusing namespace __gnu_pbds;\n\n// Treap supporting duplicating values in set\n// Maximum value of treap*ADD must fit in long long\n\nstruct Treap{\n int len;\n const int ... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 0 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n int totalApples = 0;\n for (int num : apple) {\n totalApples += num;\n }\n\n sort(capacity.begin(), capacity.end(), greater<int>());\n int boxes = 0, currentCapacity ... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 0 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n \n int comp = 0;\n \n for(int i=0; i < apple.size(); i++){\n comp += apple[i];\n \n }\n\n int tot=0;\n int count=0;\n\n sort(capacity... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 0 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n sort(capacity.begin(),capacity.end(), greater<int>());\n int coun =0;\n for(int c=0;c<apple.size();c++){\n coun+=apple[c];\n }\n \n for(int c=0;c<capacity.size... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 0 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n int ans = 0;\n int sum = 0;\n for(int i = 0; i<apple.size(); i++){\n sum += apple[i];\n }\n sort(capacity.begin(), capacity.end());\n for(int i = capacity.size... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 0 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n sort(capacity.begin(),capacity.end());\n int i=capacity.size()-1;\n int sum=0;\n for(int j=0;j<apple.size();j++){\n sum+=apple[j];\n }\n while(sum>0){\n ... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 0 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n sort(capacity.begin(),capacity.end());\n int sum=0;\n for(int i=0;i<apple.size();i++){\n sum+=apple[i];\n }\n int count=0,i=capacity.size()-1;\n while(sum>0){\... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 0 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n int sum = 0;\n for(const auto a : apple)\n {\n sum += a;\n }\n size_t numberBoxes = 0;\n sort(capacity.begin(), capacity.end(), std::greater<int>());\n ... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 2 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n int totalApples = 0;\n int boxes = 0;\n for(int i =0; i< apple.size(); i++) {\n totalApples+= apple[i];\n }\n\n sort(capacity.begin(), capacity.end());\n\n for... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 2 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n int totalApples = 0;\n int boxes = 0;\n for (int i = 0; i < apple.size(); i++) {\n totalApples += apple[i];\n }\n\n sort(capacity.begin(), capacity.end());\n\n ... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 3 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& a, vector<int>& b) {\n int n = a.size(), m = b.size();\n int sum = 0, ans = 0;\n for(int i = 0; i < n; i++) sum += a[i];\n priority_queue<int>pq(b.begin(), b.end());\n while(sum) {\n int mn = min(pq.t... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 3 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n priority_queue<int>pq;\n for(auto it:capacity)\n {\n pq.push(it);\n }\n int sum=0,c=0;\n for(auto it:apple)\n {\n sum+=it;\n }\n ... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 3 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n int sum=0;\n int count=0;\n sort(capacity.rbegin(),capacity.rend());\n for(int i=0;i<apple.size();i++)\n {\n sum+=apple[i];\n }\n for(int i=0;i<capacity... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 3 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n int cnt=0;\n sort(capacity.rbegin(),capacity.rend());\n int sum=0;\n for(int i=0;i<apple.size();i++){\n sum+=apple[i];\n }\n for(int i=0;i<capacity.size();i++)... |
3,334 | <p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p>
<p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co... | 3 | {
"code": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n int at = accumulate(apple.begin(),apple.end(),0);\n sort(capacity.rbegin(),capacity.rend());\n int count=0;\n for(auto x:capacity){\n if(at<=0)break;\n at-=x;\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n = static_cast<int>(arr.size());\n std::vector<std::string> result(n);\n for (int i = 0; i < n; ++i)\n {\n int m = static_cast<int>(arr[i].size());\n for (int j =... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n = static_cast<int>(arr.size());\n std::vector<std::string> result(n);\n for (int i = 0; i < n; ++i)\n {\n int m = static_cast<int>(arr[i].size());\n for (int j =... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\n int go[105*22*22][26];\n bitset<105> mask[105*22*22];\n int cc = 0;\n void insert(const string& s, int start, int id){\n int x = 0;\n for(int i=start;i<s.size();i++){\n int c = s[i]-'a';\n if(!go[x][c]){\n go[x][c] = ++cc;\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n string lex(string s, string t) {\n if(s == \"\") {\n return t;\n }\n if(t == \"\") {\n return s;\n }\n if(s.size() > t.size()) {\n return t;\n }\n if(t.size() > s.size()) {\n return s... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n = arr.size();\n vector<string> ans;\n for (int i = 0; i < n; ++i) {\n string cc = \"\";\n for (int j = 0; j < n; ++j) {\n if (i != j) {\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\n string lexoSmallest(string a, string b) {\n if (a == \"\") return b;\n if (b == \"\") return a;\n if (a.size() > b.size()) return b;\n if (a.size() < b.size()) return a;\n return min(a, b);\n }\n\npublic:\n vector<string> shortestSu... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\n string lexoSmallest(string a, string b) {\n if (a == \"\") return b;\n if (b == \"\") return a;\n if (a.size() > b.size()) return b;\n if (a.size() < b.size()) return a;\n return min(a, b);\n }\n\npublic:\n vector<string> shortestSu... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\n string lexoSmallest(string a, string b) {\n if (a == \"\") return b;\n if (b == \"\") return a;\n if (a.size() > b.size()) return b;\n if (a.size() < b.size()) return a;\n return min(a, b);\n }\n\npublic:\n vector<string> shortestSu... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n unordered_map<string_view, int> substr_cnt;\n \n string Calc(string_view s) {\n for (int i = 0; i < s.size(); ++i) {\n for (int j = i; j < s.size(); ++j) {\n substr_cnt[s.substr(i, j - i + 1)]--;\n }\n }\n \n string_view res;\n for (int i = 0; ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n using ull = unsigned long long;\n ull seed = 131;\n \n set<ull> cal(const string& str) {\n set<ull> s;\n for (int i = 0; i < str.size(); i++) {\n ull hash = 0;\n for (int j = i; j < str.size(); j++) {\n hash = hash *... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n bool static compare(string &s1, string &s2){\n int len = min(s1.length(), s2.length());\n for(int i = 0; i < len; i++){\n if(s1[i] < s2[i]) return true;\n else if(s1[i] == s2[i]) continue;\n else return false;\n }\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n bool check(int ind,string& checkWord,vector<string>&arr){\n for(int k = 0;k<arr.size();k++){\n if(ind==k)continue;\n string word = arr[k];\n if(word==checkWord)return true; \n for(int i = 0;i<word.size();i++){\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n=arr.size();\n vector<string> ans;\n for(int i=0;i<n;i++){\n string s=arr[i];\n int sz=s.size();\n bool finalStr=1;\n for(int l=1;l<=sz;l++){\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n bool check(int ind,string& checkWord,vector<string>&arr){\n for(int k = 0;k<arr.size();k++){\n if(ind==k)continue;\n string word = arr[k];\n if(word==checkWord)return true; \n for(int i = 0;i<word.size();i++){\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n\n// this fn check if the substring-str exists in arr\n bool check(string str,int idx,vector<string>&arr){\n for(int i=0;i<arr.size();i++){\n if(i!=idx){\n string str1=arr[i];\n size_t found = str1.find(str);\n if ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n vector<set<string>> subs(arr.size());\n string temp;\n bool satisfied;\n set<string> same;\n vector<string> answer;\n for(int k=0;k<arr.size();k++)\n {\n for... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n=arr.size();\n vector<string>ans(n);\n map<string,int>h;\n for(int i=0;i<n;i++){\n string s=arr[i];\n int m=s.size();\n for(int j=0;j<m;j++){\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n map<string, int >mp;\n for(int i=0;i<arr.size();i++)\n {\n for(int j=0;j<arr[i].size();j++)\n {\n string temp=\"\";\n for(int k=j;k<arr[i].size(... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n string getmin(string &result, string &c) {\n if (result.size() < c.size())\n return result;\n else if (result.size() > c.size())\n return c;\n return min(result, c);\n }\n \n vector<string> shortestSubstrings(vector<string>&... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n unordered_map<string,pair<int,int> >mp; //str idx cnt\n int n = arr.size();\n for(int i = 0; i < n; i++){\n int slen = arr[i].length();\n for(int j = 0; j < slen; j++){\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "#include <vector>\n#include <string>\n#include <unordered_map>\n#include <algorithm>\n#include <iostream>\n\nusing namespace std;\n\nclass Solution {\npublic:\n void find_all_substrings(const string& s, unordered_map<string, int>& m) {\n int n = s.size();\n for (int i = 0; i < n; i++) \n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n=arr.size();\n unordered_map<string,int> freq;\n for(auto s:arr){\n int m=s.size();\n for(int i=0; i<m; i++){\n for(int j=i; j<m; j++){\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n = arr.size();\n vector<string> ret(n, \"\");\n for (int i = 0; i < n; ++i) {\n vector<string> subs = generateSubstrings(arr[i]);\n for (const auto& sub : subs) {\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n auto generateSubstrings = [](const string& s) {\n vector<string> subs;\n for (int i = 0; i < s.size(); ++i) {\n string sub;\n for (int j = i; j < s.size(); ++... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n string compp(string &a,string &b){\n int i=0;\n while(i<a.size()){\n if(a[i]<b[i]) return a;\n else if(b[i]<a[i]) return b;\n i++;\n }\n return a;\n }\n vector<string> shortestSubstrings(vector<string>& arr) {... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n string findShortest(const string& s, unordered_map<string, vector<int>>& mp)\n {\n string res = \"\";\n for(int i=0;i<s.size();++i)\n {\n string temp = \"\";\n for(int j=i;j<s.size();++j)\n {\n temp += s[... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n bool check(vector<string> &arr,string temp,int ind,unordered_map<int,unordered_map<string,int>> &mp){\n for(int i=0;i<arr.size();i++){\n if(i==ind){\n // cout<<ind<<\" \";\n continue;\n }\n else{\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n=arr.size();\n map<string,vector<int>>mp;\n for(int i=0;i<n;i++){\n string s=arr[i];\n int n1=s.size();\n for(int j=0;j<n1;j++){\n string s1=\"... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n unordered_map<unsigned long long, int> mp;\n int l = arr.size();\n vector<unordered_map<unsigned long long, int>> mps(l);\n \n for (int k = 0; k < l; ++k) {\n string s = ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 0 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n unordered_map<string, vector<int>> substrFreq;\n vector<string> result;\n\n for (int k = 0;k<arr.size(); k++) {\n string str = arr[k];\n for (int i = 0; i < str.length(); ++i... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution\n{\npublic:\n vector<string> shortestSubstrings(vector<string> &arr)\n {\n vector<string> res;\n vector<vector<string>> substring;\n for (string &s : arr)\n {\n vector<string> temp;\n for (int j = 0; j < s.length(); j++)\n {\... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n map<string, int> sub;\n unordered_map<string, vector<string>> dp;\n vector<string> res(arr.size());\n for (int i=0; i<arr.size(); ++i) subString(arr[i], sub, i);\n for (auto &x: sub)... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "static int io_opt = []() {\n std::ios::sync_with_stdio(false);\n return 0;\n}();\n\nclass Solution {\n public:\n vector<string> shortestSubstrings(vector<string>& arr) {\n unordered_map<string, int> mcount;\n unordered_set<string> tmset;\n string buf;\n int size;\n for (auto& str : arr) {... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "static int io_opt = []() {\n std::ios::sync_with_stdio(false);\n return 0;\n}();\n\nclass Solution {\n public:\n vector<string> shortestSubstrings(vector<string>& arr) {\n unordered_map<string, int> mcount;\n unordered_set<string> tmset;\n string buf;\n int size;\n for (auto& str : arr) {... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n unordered_map<string,int> f;\n unordered_set<string> g;\n vector<string> shortestSubstrings(vector<string>& a) {\n for (string x:a) {\n int l=x.size();\n g.clear();\n for (int i=1;i<=l;i++) {\n for (int j=0;j+i<=l;j... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n unordered_map<string, int> m;\n unordered_map<int, set<string>> ms;\n for (int i = 0; i < arr.size(); i++) {\n for (int j = 0; j < arr[i].length(); j++) {\n for (int k = j; k ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n=arr.size();\n map<string,int>map;\n unordered_map<string,int>unmap;\n string sub;\n int pos;\n vector<string> result;\n result.resize(n);\n for(int i=0;i<n... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n=arr.size();\n map<string,int>map;\n unordered_map<string,int>unmap;\n string sub;\n int pos;\n vector<string> result;\n result.resize(n);\n for(int i=0;i<n... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n int n = arr.size();\n unordered_map<string, set<int> > mp;\n\n for (int i = 0; i < n; i++) {\n int len = arr[i].size();\n for (int j = 0; j < len; j++) {\n str... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(const vector<string>& arr) {\n const int n = (int)arr.size();\n unordered_map<string, int> mp;\n vector<vector<unordered_set<string>>> subs(n);\n for (int i = 0; i < n; i++) {\n const auto &s = arr[i];\n... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n unordered_map<string, set<int>> mp;\n\n for(int ind=0;ind<arr.size();ind++)\n {\n string str = arr[ind];\n int n = str.length();\n for(int i=0;i<n;i++)\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n vector<string> v;\n map<string, int> mp;\n\n \n for (int i = 0; i < arr.size(); i++) {\n string s1 = arr[i];\n unordered_set<string> seenSubstrings;\n for ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n vector<string> result;\n unordered_map<string, int> unique_substr;\n\n for (string& str : arr) {\n\n unordered_set<string> seen; //Explained in video why we need this seen\n\n ... |
3,356 | <p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p>
<p>Find a string array <code>answer</code> of size <code>n</code> such that:</p>
<ul>
<li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ... | 1 | {
"code": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n unordered_map<string,int> mpp;\n vector<string> res;\n for(string &s: arr){\n unordered_set<string> st;\n for(int i = 0;i<s.length();i++){\n for(int j = i+1;j<... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.