id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class SegmentTree {\n vector<int> tree;\n int n;\n \npublic:\n SegmentTree(int size) : n(size) {\n tree.resize(4 * n, 0); // Segment Tree needs space 4 times the input size\n }\n \n // Update the segment tree at index `idx` to value `val`\n void update(int node, int start, i... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "#include <vector>\n#include <algorithm>\n#include <unordered_map>\n\nusing namespace std;\n\nclass SegmentTree {\npublic:\n SegmentTree(int size) : size(size) {\n tree.assign(4 * size, 0);\n }\n\n void update(int pos, int value, int start, int end, int node) {\n if (start == end) {\n... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n void segtr(vector<int>&st,int a[],int i,int l,int r){\n if(l==r) {\n st[i]=a[l];\n return;\n }\n int m=(l+r)/2;\n segtr(st,a,2*i+1,l,m);\n segtr(st,a,2*i+2,m+1,r);\n st[i]=max(st[2*i+1],st[2*i+2]);\n }\n int getsum(vector<int>&st,int i,in... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n int maxPathLength(vector<vector<int>>& coordinates, int k) {\n int x= coordinates[k][0],y=coordinates[k][1];\n int n=coordinates.size();\n set<int> s,st;\n map<int,vector<int>> m;\n for(int i=0;i<n;i++){\n if(coordinates[i][0]!=x)... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "int N;\nstruct SegTree {\n\n int value;\n SegTree* left;\n SegTree* right;\n\n SegTree() { \n this->value = 0; \n this->left = NULL;\n this->right = NULL;\n }\n\n void change(SegTree* root, int l, int r, int pos, int value) {\n if (l == r) {\n root->... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "int N;\nstruct SegTree {\n\n int value;\n SegTree* left;\n SegTree* right;\n\n SegTree() { \n this->value = 0; \n this->left = NULL;\n this->right = NULL;\n }\n\n void change(SegTree* root, int l, int r, int pos, int value) {\n if (l == r) {\n root->... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n int t[800050];\n void build(int v, int tl, int tr){\n if(tl == tr){\n t[v] = 0;\n return;\n }\n int mid = (tl+tr)/2;\n build(2*v,tl,mid);\n build(2*v+1,mid+1,tr);\n t[v] = max(t[2*v],t[2*v+1]);\n }\n voi... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "#include <bits/stdc++.h>\n\n#define FOR(i, l, r) for (int i = l; i < r; ++i)\n#define FORR(i, r, l) for (int i = r; i >= l; --i)\n#define FORI(n) FOR(i, 0, n)\n#define FORJ(n) FOR(j, 0, n)\n#define FORK(n) FOR(k, 0, n)\n#define loop(n) FOR(_, 0, n)\n#define all(x) x.begin(), x.end()\n#define sz(x) x.size()... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 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 maximum(int idx, int s,... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "#include<bits/stdc++.h>\nusing namespace std;\n#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\ntypedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;\n//#pragma GCC target(\"avx2\")\n//order_of_key #of el... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n int maxPathLength(vector<vector<int>>& coordinates, int k) {\n int n = coordinates.size();\n\n // Coordinate compression for y values\n vector<int> ys(n);\n for (int i = 0; i < n; ++i) {\n ys[i] = coordinates[i][1];\n }\n v... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Seg {\n public:\n int n;\n vector<int> seg;\n Seg(int _n) {\n n = _n;\n seg = vector<int> (4 * n);\n }\n void update(int idx, int val, int i, int l, int r) {\n if(l == r) {\n seg[i] = max(seg[i], val);\n return;\n }\n int mid ... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n \n struct FT {\n int n;\n vector<int> bit;\n \n FT(int size) : n(size) {\n bit.assign(n + 1, 0); \n }\n \n \n int query(int idx) {\n int result = 0;\n while (idx > 0) {\n ... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n // Fenwick Tree / Binary Indexed Tree (BIT)\n struct FT {\n int n;\n vector<int> bit;\n \n FT(int size) : n(size) {\n bit.assign(n + 1, 0); // Initialize BIT array with 0\n }\n \n // Query maximum value up to ind... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n \n struct ST{\n int n;\n vector<int> t;\n ST(int n)\n {\n this->n=n;\n t.resize(4*n,0);\n }\n\n void update(int i,int l,int r,int pos,int val)\n {\n if(pos>r || pos<l)return ;\n if... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "const int N = 1e6 + 5;\nint d[N*4];\nvoid update(int x, int l, int r, int idx, int val){\n if(l==r){\n d[x]=val;\n return;\n }\n int sr=(l+r)/2;\n if(idx<=sr) update(x*2, l, sr, idx, val);\n else update(x*2+1, sr+1, r, idx, val);\n d[x]=max(d[x*2], d[x*2+1]);\n}\nint query(i... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "#define ll long long int\nclass SegmentTree {\npublic:\n SegmentTree(int n) : n(n) {\n tree.resize(4 * n, 0); // Initialize tree with minimum possible values\n }\n\n // Point update: set arr[ind] = max(arr[ind], val)\n void update(int ind, long long val, int node, int start, int end) {\... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "#include<bits/stdc++.h>\n\nusing namespace std;\ntypedef long long ll;\n#define sz(s) (int)(s).size()\n#define all(s) s.begin(),s.end()\n\nstruct Node {\n int val = 0;\n} neutral;\n\nstruct segtree {\n segtree *left = nullptr, *right = nullptr;\n\n Node node = {};\n\n int start, end;\n\n seg... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n\n int Query(std::vector<int>& tree, int target_low, int target_high, int node_idx, int low, int high){\n\n if(target_low > high || target_high < low || target_low > target_high){\n return 0;\n }\n\n if(target_low <= low && target_high >= high){... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n\n int Query(std::vector<int>& tree, int target_low, int target_high, int node_idx, int low, int high){\n\n if(target_low > high || target_high < low || target_low > target_high){\n return 0;\n }\n\n if(target_low <= low && target_high >= high){... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "struct Seg {\n int mi, ma, val, base;\n Seg *left, *right;\n Seg(vector<int>& A, int l, int r, int base) : mi(A[l]), ma(A[r]), val(base), base(base), left(nullptr), right(nullptr) {\n if(l ^ r) {\n int m = l + (r - l) / 2;\n left = new Seg(A,l,m,base);\n rig... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "struct Seg {\n int mi, ma, val, base;\n Seg *left, *right;\n Seg(vector<int>& A, int l, int r, int base) : mi(A[l]), ma(A[r]), val(base), base(base), left(nullptr), right(nullptr) {\n if(l ^ r) {\n int m = l + (r - l) / 2;\n left = new Seg(A,l,m,base);\n rig... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "// class Solution {\n// public:\n// int merge(int node1, int node2){\n// return max(node1,node2);\n// }\n\n// int left(int n){\n// return 2*n;\n// }\n\n// int right(int n){\n// return 2*n+1;\n// }\n\n// void update(int node, int s, int e, vector<int>&seg,... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n struct segtree {\n int n;\n vector <int> a;\n segtree (int m) {\n n = m;\n a.assign(4 * n, 0);\n }\n void update (int i, int v, int x, int lx, int rx) {\n if (rx - lx == 1) {\n a[x] = max(a[x],... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n\n// Source: https://github.com/atcoder/ac-library\n\n// @param n `0 <= n`\n// @return minimum non-negative `x` s.t. `n <= 2**x`\nint ceil_pow2(int n) {\n int x = 0;\n while ((1U << x) < (unsigned int)(n)) x++;\n return x;\n}\n\ntemplate <class S, S ... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n\n// Source: https://github.com/atcoder/ac-library\n\n// @param n `0 <= n`\n// @return minimum non-negative `x` s.t. `n <= 2**x`\nint ceil_pow2(int n) {\n int x = 0;\n while ((1U << x) < (unsigned int)(n)) x++;\n return x;\n}\n\ntemplate <class S, S ... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class seg\n{\n public:\n vector<int>tree;\n map<int,int>mp;\n int n;\n seg(set<int>&v)\n {\n n=v.size();\n tree.resize(4*n);\n int in=0;\n for(auto i:v) mp[i]=in++;\n }\n void upd(int node,int st,int en,int y,int ans)\n {\n if(st>y || en<y) retu... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n using ll=long long;\nstruct seg {\n ll n;\n vector<ll> a;\n seg(ll n) {\n this->n=n;\n a.resize(n*4+5,0);\n }\n void up(ll v,ll l,ll r,ll p,ll val) {\n if(l>p||r<p) return;\n if(l==r) {\n a[v]=max(a[v],val);\n return;\n }\n ll m=(l+r)>>1;\... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n using ll=long long;\nstruct seg {\n ll n;\n vector<ll> a;\n seg(ll n) {\n this->n=n;\n a.resize(n*4+5,0);\n }\n void up(ll v,ll l,ll r,ll p,ll val) {\n if(l>p||r<p) return;\n if(l==r) {\n a[v]=max(a[v],val);\n return;\n }\n ll m=(l+r)>>1;\... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\n#define dbg(x) cout << #x << \" = \" << x << \"\\n\"\n#define pb push_back\n#define fi first\n#define se second\n#define INF 1e18\n#define all(x) (x).begin(), (x).end()\n#define set_bits(x) __builtin_popcountll(x)\nclass STLazy{\n pu... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n struct st{\n int sz = 1;\n vector<int> v;\n\n st(int n){\n while(sz < n) sz *= 2;\n v.resize(2*sz);\n }\n\n void upd(int u, int k){\n u += sz;\n if(v[u] >= k) return;\n v[u] = k;\n\n ... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class BIT {\npublic:\n vector<int> bit;\n BIT(int n) {\n bit.resize(n + 1, 0);\n }\n\n void update(int i, int val) {\n while (i < bit.size()) {\n bit[i] = max(bit[i], val);\n i += (i & -i);\n }\n }\n\n int query(int i) {\n int res = 0;\n ... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n vector<int> ftree;\n void update(int i, int del){\n for(i++; i < ftree.size(); i+=(i&-i)){\n ftree[i] = max(ftree[i], del);\n }\n }\n int query(int i){\n int ans = 0;\n for(++i; i>0; i-=(i&-i)){\n ans = max(ans, ftree... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "class Solution {\npublic:\n\n using ll = long long;\n const int N = 1e5 + 5;\n \n template<class T> struct Seg {\n const T ID = 0;\n T comb(T a, T b) {\n return max(a,b);\n }\n int n;\n vector<T> seg;\n void init(int _n) {\n n = _n... |
3,571 | <p>You are given a 2D array of integers <code>coordinates</code> of length <code>n</code> and an integer <code>k</code>, where <code>0 <= k < n</code>.</p>
<p><code>coordinates[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> indicates the point <code>(x<sub>i</sub>, y<sub>i</sub>)</code> in a 2D plane.</p>
<p>An <st... | 3 | {
"code": "int absoll(int a){\n if(a<0) return -a;\n return a;\n}\nvoid solve(vector<int> arr, int x, vector<int>& vec,map<pair<int,int>,int>& dp) {\n sort(arr.begin(), arr.end(), greater<int>());\n for(int i = 0; i < arr.size(); i++) {\n int pos = lower_bound(vec.begin(), vec.end(), arr[i]) - vec.... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int>result;\n for(int i=0;i<nums.size();i++){\n for(int j=i+1;j<nums.size();j++){\n if(nums[i]==nums[j]){\n result.push_back(nums[i]);\n }\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int x=-1,y=-1,idx,n=nums.size();\n for(int i=0;i<n;i++){\n idx=nums[i]<0?n+nums[i]:nums[i];\n if(nums[idx]<0){\n if(x==-1)x=idx;\n else y=idx;\n }e... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& v) {\n\n int xr = 0;\n int m = v.size();\n int n = v.size()-2;\n\n for(int i=0; i<m; i++) {\n xr = xr^v[i];\n }\n\n for(int i=0; i<n; i++) {\n xr = xr^i;\n }\n\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int> ans;\n\n for(int i = 0;i<nums.size();i++){\n for(int j = i+1;j<nums.size();j++){\n if(nums[i]==nums[j]){\n ans.push_back(nums[i]);\n i... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n\n int xorSum = 0;\n int totalSize = nums.size();\n int actualSize = nums.size() - 2;\n\n // XOR all elements of the array\n for(int i = 0; i < totalSize; i++) {\n xorSum ^= nums[... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int> ans;\n int i=0;\n int j=1;\n while(true){\n \n if(nums[i]==nums[j]){\n ans.push_back(nums[i]); \n }\n if(j==nums.size()-1){\... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums)\n {\n vector<int> ans;\n sort(nums.begin(),nums.end());\n for(int i=1;i<nums.size();i++)\n {\n if(nums[i]==nums[i-1])\n {\n ans.push_back(nums[i]);\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int n = nums.size()-2;\n vector<int> hash(n, 0);\n vector<int> ans;\n for(int i=0; i<n+2; i++){\n hash[nums[i]]++;\n if(hash[nums[i]] == 2){\n ans.push_back(nu... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(),nums.end());\n \n vector<int> ans;\n for(int i=1;i<n;i++){\n if(nums[i] == nums[i-1]){\n ans.push_back(nums[i]);\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int> ans;\n \n sort(nums.begin(),nums.end());\n for(int i=0;i<nums.size()-1;i++)\n {\n if(nums[i]==nums[i+1])\n {\n ans.emplace_back(nums[i]);\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n \n sort(nums.begin(),nums.end());\n\n vector<int> ans; \n for(int i=1;i<nums.size();i++){\n if(nums[i-1]==nums[i]) ans.push_back(nums[i]);\n }\n return ans;\n }... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int>freq(nums.size());\n for(auto it:nums){\n freq[it]++;\n }\n vector<int>ans;\n for(int i=0;i<freq.size();i++){\n if(freq[i]>1) ans.push_back(i);\n }\n... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int> res;\n vector<int> freq(nums.size(), 0);\n for (const int& n : nums) {\n freq[n]++;\n\n if (freq[n] == 2) {\n res.push_back(n);\n }\n }\... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int cnt[100];\n vector<int> ans;\n for (int n : nums) {\n cnt[n]++;\n if (cnt[n] > 1) ans.push_back(n);\n }\n return ans;\n }\n};",
"memory": "25400"
} |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 0 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int> freq(100);\n for(int i : nums)\n freq[i]++;\n int i = 0, c = 2;\n\n vector<int> ans;\n\n while(c != 0){\n if(freq[i] == 2){\n ans.push_back(... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int n = nums.size();\n\n vector<int> temp(n-2,0);\n vector<int> ans;\n\n for(int it: nums){\n if(temp[it]==1) ans.push_back(it);\n temp[it]++;\n }\n\n return an... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n\n vector<int> v(nums.size(),0);\n for(int n:nums)\n {\n v[n]++;\n }\n\n vector<int> sek;\n for(int i=0;i<nums.size();i++)\n {\n if(v[i]==2)\n {\n sek.... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int n=nums.size();\n n-=2;\n vector<int> temp(n,0);\n vector<int> ans;\n for(auto i:nums)\n {\n temp[i]++;\n if(temp[i]==2)ans.push_back(i);\n }\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int n=nums.size();\n vector<int>v(n,0);\n vector<int>res;\n \n for(auto i: nums)\n {\n v[i]++;\n if(v[i]==2)\n {\n res.push_back(i);\n... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int arr[101] = {0};\n vector<int>ans;\n for(int i:nums){\n arr[i]++;\n if(arr[i]>=2) ans.push_back(i);\n }\n return ans;\n }\n};",
"memory": "25700"
} |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int a[101] = {0};\n vector<int> ans;\n for(auto i:nums)\n {\n a[i]++;\n if(a[i]>1)\n ans.push_back(i);\n if(ans.size()==2)\n return a... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int a[101]={0};\n\n for(int i=0;i<nums.size();i++)\n a[nums[i]]++;\nvector<int>ans;\n for(int i=0;i<=100;i++)\n {\n if(a[i]==2)\n ans.push_back(i);\n }\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int a[200]={0};\n vector<int> ans;\n for(int i=0;i<nums.size();i++){\n a[nums[i]]++;\n }\n int i=0;\n int j=nums.size()-1;\n while(i<=j){\n if(i!=j){\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n int n = nums.size();\n stack<int> st;\n \n vector<int> ans;\n\n sort(nums.begin(),nums.end());\n\n for(int i = 0 ; i <n ; i++ )\n {\n while(!st.empty() && nums[i] == st... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "#include <set>\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n set<int> s;\n vector<int> result;\n for (auto num : nums) {\n if (s.find(num) == s.end()) {\n s.insert(num);\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n set<int>st;\n vector<int>ans;\n for(int i = 0;i<nums.size();i++){\n if(st.find(nums[i])!=st.end()) ans.push_back(nums[i]);\n st.insert(nums[i]);\n }\n return ans;\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "#include <set>\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n set<int> s;\n vector<int> result;\n for (auto num : nums) {\n if (s.find(num) == s.end()) {\n s.insert(num);\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n set<int>s;\n vector<int>fAns;\n for(int i=0;i<nums.size();i++){\n if(s.find(nums[i])!=s.end())fAns.push_back(nums[i]);\n s.insert(nums[i]);\n }\n return fAns;\n }\n... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int> ans;\n std::set<int> st;\n for (auto const& n : nums) {\n if (st.find(n) == st.end())\n st.insert(n);\n else\n ans.push_back(n);\n }... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n set < int > st;\n vector < int > res;\n for ( int num: nums){\n if(st.count(num)>0){\n res.push_back(num);\n }\n st.insert(num);\n }\n return... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int>ans;\n set<int>s;\n for(int i=0;i<nums.size();i++)\n {\n if(s.find(nums[i])!=s.end())\n {\n ans.push_back(nums[i]);\n }\n else... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n set<int> s;\n vector<int> ans;\n for(int i=0;i<nums.size();i++){\n if(s.find(nums[i]) != s.end()){\n ans.push_back(nums[i]);\n continue;\n }\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n set<int>st;\n vector<int>ans;\n for(int i = 0;i<nums.size();i++){\n if(st.find(nums[i])!=st.end()) ans.push_back(nums[i]);\n st.insert(nums[i]);\n }\n sort(ans.begin()... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n multiset<int>s;\n for(int a=0;a<nums.size();a++){\n s.insert(nums[a]);\n }\n vector<int>v;\n for(auto i : s){\n if(s.count(i)>1){\n if(v.size()==0){\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n set<int> st;\n sort(nums.begin(), nums.end());\n vector<int> ans;\n for(auto it : nums){\n if(st.find(it) != st.end()){\n ans.push_back(it);\n }\n e... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n\n map<int,int> a;\n\n vector<int> r;\n\n for(auto i: nums){\n a[i]++;\n if(a[i]==2) r.push_back(i);\n\n if(r.size()==2) return r;\n }\n return r;\n }\n};... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int>ans;\n map<int, int>mp;\n int b=0;\n for(auto it: nums){\n mp[it]++;\n if(mp[it]==2){\n ans.push_back(it);\n b++;\n if... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n unordered_map<int,int> xmap;\n vector<int> ans;\n int kk=0;\n for(int i=0; i!=nums.size();i++){\n if(!xmap.count(nums[i])){\n xmap[nums[i]]=i;\n }else{\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n map<int,int>mp;\n vector<int>ans;\n\n for(int i=0;i<nums.size();i++)\n {\n mp[nums[i]]++;\n\n if(mp[nums[i]] == 2)\n ans.push_back(nums[i]);\n\n if(... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n map<int, int> freq;\n vector<int> res(2);\n int i=0;\n for(int ele: nums) {\n if(freq[ele] == 1) {\n res[i++] = ele;\n if(i == 2) break;\n }\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int>ans;\n unordered_map<int, int>mp;\n for(auto &x: nums){\n mp[x]++;\n if(mp[x]>=2) ans.push_back(x);\n } \n return ans;\n }\n};",
"memory": "26900"
} |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n static vector<int> byMap(vector<int>& nums){\n vector<int> ans;\n map<int,int> map1;\n for(int x:nums){\n map1[x]++;\n }\n for(const auto&[key,value]:map1){\n if(value>1){\n ans.push_back(key);\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n unordered_map<int,int> mp;\n vector<int> ans;\n for(int i=0;i<nums.size();i++){\n mp[nums[i]]++;\n if(mp[nums[i]]==2) ans.push_back(nums[i]);\n }\n return ans;\n }\... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n unordered_map<int,int> map;\n vector<int> res;\n for(int i=0;i<nums.size();i++){\n map[nums[i]]++;\n }\n for(auto i:map)\n {\n if(i.second>1){\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& numss) {\n map<int,int> mp;\n vector<int> ans;\n for(auto nums:numss)\n {\n mp[nums]++;\n if(mp[nums]==2)\n ans.push_back(nums);\n }\n return ans;\n \n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 1 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n unordered_map<int, int> mpp;\n vector<int> ans;\n \n // Count the occurrences of each number in nums\n for(int i = 0; i < nums.size(); i++) {\n mpp[nums[i]]++; // Corrected:... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int> sneakyNumbers;\n unordered_map<int, int> freq;\n for (int num: nums) {\n freq[num]++;\n if (freq[num] == 2) {\n sneakyNumbers.push_back(num);\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n vector<int> ans;\n \n unordered_map<int,int> mp;\n \n for (const auto &it : nums) {\n mp[it]++;\n }\n \n for (const auto &it : mp) {\n if (it.seco... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n unordered_map<int,int> m;\n for(int i=0;i<nums.size();i++)\n {\n m[nums[i]]++;\n }\n vector<int> ans;\n for(auto i:m )\n {\n if(i.second==2){\n ... |
3,581 | <p>In the town of Digitville, there was a list of numbers called <code>nums</code> containing integers from <code>0</code> to <code>n - 1</code>. Each number was supposed to appear <strong>exactly once</strong> in the list, however, <strong>two</strong> mischievous numbers sneaked in an <em>additional time</em>, making... | 2 | {
"code": "class Solution {\npublic:\n vector<int> getSneakyNumbers(vector<int>& nums) {\n unordered_map<int,int> m;\n vector<int> ans;\n for(auto i : nums) {\n if(m[i] == 1) {\n ans.push_back(i);\n } else {\n m[i] += 1;\n }\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n long long dp[5];\n for(int i=1;i<=4;i++)\n dp[i]=-1e18;\n \n \n dp[0]=0;\n for(int i=0;i<b.size();i++){\n for(int j=3;j>=0;j--){\n if(dp[j]!=-1... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n long long a1,a2,a3,a4;\n a1=a2=a3=a4=INT_MIN;\n for(long long i:b){\n a4=max(a4,a3+(long long)a[3]*i);\n a3=max(a3,a2+(long long)a[2]*i);\n a2=max(a2,a1+(long long)a[1... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n \n int n=b.size();\n \n long long int dp[n];\n memset(dp,0,sizeof(dp));\n for(int j=3;j>=0;j--){\n \n long long int dp1[n];\n memset(dp1,0,sizeof(dp1)... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n void shift() {\n\n }\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n long long ans = -1e18;\n stack<int> st;\n long long mx = max(b[n-1], b[n-2]), mn = min(b[n-1], b[n-2]);\n st.push(n-2);\n unordere... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "long long DP[100001][4];\n\nclass Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n memset(DP, 200, sizeof(DP));\n //cout << DP[0][0] << '\\n';\n for (int i = 0; i != b.size(); ++i) {\n DP[i + 1][0] = max(DP[i][0], (long long)a[0] * b[i]);\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "using i64 = long long;\n\nconstexpr int MAX = 100010;\nconstexpr i64 INF = 0x3F3F3F3F3F3F3F3FLL;\n\ni64 dp[4][MAX];\n\nclass Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n dp[0][0] = (i64)a[0] * (i64)b[0];\n for (int i = 1; i < n; ++i) {\n... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n #define ll long long\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n ll dp[5][n+1]; // dp[i][j] represents max score using first i elements from a and first j elements from b\n \n // Initialize dp array with negativ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n using ll = long long;\n ll INF = 2e18;\n ll DP[n][5];\n memset(DP, 0, sizeof(DP));\n DP[0][1] = 1ll * a[0] * b[0];\n for (int i = 1; i < n; i++) {\n ... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\n #define ll long long int\n #define nax 200005\n ll value[nax][4];\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n for(int i = 0; i < n; i++)for(int j = 0; j < 4; j++) value[i][j] = INT_MIN;\n value[0][0] = max(value[0... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "const int maxn = 5 + 1e5;\nclass Solution {\npublic:\n long long dp[maxn][4], mx[maxn][4];\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n for (int i = 0; i <= n; ++i) for (int j = 0; j < 4; ++j) dp[i][j] = mx[i][j] = -1e18;\n for(int i = 1; i <= n; +... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n long long int dp[5][n+5];\n long long int maxi[5][n+5];\n for (int i=0; i<=4; i++) dp[i][0] = -1e9;\n for (int i=0; i<=n; i++) dp[0][i] = 0;\n for (int i=0; i<... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n int64_t dp[100009][9];\n\n long long maxScore(vector<int>& a, vector<int>& b) {\n int n = b.size();\n int k = 4;\n memset(dp, 0, sizeof(dp));\n\n for (int j = 1; j <= 4; j++) {\n for (int i = j; i <= n; i++) {\n dp[i][j... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n const int M = a.size();\n const int N = b.size();\n vector< long long > dp(N + 1);\n \n for (int i = 1; i <= M; ++i) {\n auto prev = dp[0];\n\n dp[0] = INT_MIN;\n\n... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n const int n = b.size();\n vector<long long> rights(n);\n long long max_tail = LLONG_MIN;\n for (int i = n - 1; i >= 0; --i) {\n if (i == n - 2) {\n rights[i] = 1LL * a... |
3,518 | <p>You are given an integer array <code>a</code> of size 4 and another integer array <code>b</code> of size <strong>at least</strong> 4.</p>
<p>You need to choose 4 indices <code>i<sub>0</sub></code>, <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>, and <code>i<sub>3</sub></code> from the array <code>b</code> s... | 0 | {
"code": "class Solution {\npublic:\n long long maxScore(vector<int>& a, vector<int>& b) {\n long long dp0= LLONG_MIN, dp1 = LLONG_MIN, dp2 = LLONG_MIN, res = LLONG_MIN;\n \n for(int i=b.size()-1; i>=0;i--){\n if(dp0 != LLONG_MIN) res = max(res,dp0 + 1ll * a[0] * b[i]);\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.