id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if(k==1)\n return nums;\n int n=nums.size(),count=0;\n vector<int> ans;\n deque<bool> q;\n for(int i=1;i<k;i++)\n {\n if(nums[i]!=nums[i-1]+1)\n {... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if(k==1)\n return nums;\n vector<int> pow;\n int a=nums[0];\n queue<int > no;\n for(int i=1;i<k;i++){\n if(nums[i]-a!=1){\n no.push(i-1);\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n queue<int> store;\n int n = nums.size();\n for (int i = 1; i < n; i++) {\n if (nums[i - 1] >= nums[i] or nums[i] - nums[i - 1] >= 2) {\n store.push(i);\n }\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> st;\n vector<int> ans;\n for(int i=0; i<k; i++){\n if(st.empty()){\n st.push_back(nums[i]);\n }\n else{\n int top = st.back()... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> answer;\n deque<int> dq;\n int i = 0;\n int j = 0;\n int indx=INT_MIN;\n\n bool check = true;\n\n while (j < nums.size()) {\n\n if (!dq.empty() && dq... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n int prev = 0;\n int next = k;\n int mis = -1;\n vector<int> ans;\n deque<int> q;\n q.push_back(0);\n for(int i = 1;i<k;i++){\n if(... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n deque<int>q;\n \n vector<int>ans;\n int j=0;\n for(int i=0;i<nums.size();i++)\n {\n \n // [3,2,3,2,3,2]\n \n if(!q.empty() && ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "int counts[1000005];\n\nclass Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if (k == 1) {\n return nums;\n }\n memset(counts, 0, sizeof(counts));\n int inverses = 0, kinds = 1;\n vector <int> results;\n ++counts[nums[0]]... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if(k==1) return nums;\n int n = nums.size();\n vector<int>ans;\n vector<int>violation;\n for(int i=1;i<n;i++){\n if(nums[i-1]+1!=nums[i]){\n violation.push_back... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n deque<int>Q;\n for(int i = 0;i < k - 1;i++){\n if(!Q.empty()&& nums[Q.back()] + 1 == nums[i]){Q.pop_back();}\n Q.push_back(i);\n }\n vector<int>res;\n for(int i = ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "#include <iostream>\n#include <vector>\n#include <deque>\n\nusing namespace std;\n\nclass Solution\n{\npublic:\n vector<int> resultsArray(vector<int> &nums, int k)\n {\n int n = nums.size();\n deque<int> res;\n deque<int> neg;\n vector<int> ans(n - k + 1, 0);\n if (... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if (k == 1) return nums;\n int size = nums.size();\n vector<int> ans;\n bool sorted = true;\n queue<pair<int,int>> q;\n for (int i = 1; i<k; i++){\n if ((nums[i] - nums... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n\n if(k==1)\n return nums;\n \n priority_queue<int,vector<int>,greater<int>>pq;\n \n for(int i=1;i<n;i++)\n { \n if(nums[i]!=nums[i-1]+1)... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n =nums.size();\n if(k==1)return nums;\n priority_queue<int> pq;\n pq.push(nums[0]);\n int last_ind=-1;\n int i=0;\n vector<int> ans;\n for(int j=1;j<n;j++){\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n deque<int> dq;\n vector<int> ans;\n for(int i = 0; i < nums.size(); i++)\n {\n while(!dq.empty() && i - dq.front() + 1 > k) dq.pop_front();\n while(!dq.empty() && nums[dq.... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n \n int n = nums.size();\n vector<int> result;\n deque<int> due;\n\n for(int i = 0 ; i < n ; i++){\n\n if(due.empty() || due.back() + 1 == nums[i]){\n due.push_bac... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n \n int n = nums.size();\n int tail = 0 ;\n int head = 0 ;\n vector<int>ans(n,-1);\n\n while(tail < n){\n while(head+1 < n && nums[head+1] == nums[head]+1){\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 2 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if (k == 1)\n return nums;\n int n = nums.size();\n vector<int> ans;\n vector<int> cons(n, 1);\n for (int i = 1; i < n; i++) {\n if (nums[i] == nums[i - 1] + 1)\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n if(n==1 or k==1)\n return nums;\n vector<int> x(n-1,0);\n for(int i=0;i<n-1;i++){\n x[i]=nums[i+1]-nums[i];\n }\n vector<int> ans;\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n\tvector<int> resultsArray(vector<int>& a, int k) {\n\t\tdeque<int> q;\n\t\tvector<int> ans;\n\t\tfor (int i = 0; i < a.size(); i++) {\n\t\t\tq.push_back(a[i]);\n\t\t\tif (q.size() > 1 && q.back() != q[q.size() - 2] + 1)\n\t\t\t\tq = { a[i] };\n\t\t\twhile (q.size() > k)\n\t\t\t\... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if(k==1)\n return nums;\n vector<int>ans(nums.size(),-1);\n deque<int>pq;\n int i=0;int j=1;\n int n=nums.size();\n pq.push_back(nums[0]);\n while(j<n)\n {\n... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\nprivate:\n void clearDeque(deque<int>& dq) {\n dq.clear();\n }\n\n void pushToDeque(deque<int>& dq, int value) {\n dq.push_back(value);\n }\n\n void popFromDequeBack(deque<int>& dq) {\n dq.pop_back();\n }\n\n void popFromDequeFront(deque<int>& dq)... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "const int N = 1e5 + 5;\nint d[N*4];\nvoid build(int x, int l, int r, int n, vector<int> &tab){\n if(l==r){\n if(l<=n) d[x]=tab[l-1];\n return;\n }\n int sr=(l+r)/2;\n build(x*2, l, sr, n, tab);\n build(x*2+1, sr+1, r, n, tab);\n d[x]=max(d[x*2], d[x*2+1]);\n}\nint query(int ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n vector<pair<int,int>>a;\n int start = 0;\n int prev = nums[0];\n int end = 1;\n for(; end < n; end++){\n if(prev + 1 == nums[end]){\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n vector<pair<int,int>>v;\n for(int i=0;i<n;i++){\n int j=i+1;\n while(j<n&&nums[j]-nums[j-1]==1){\n j++;\n }\n v.push_bac... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n map<int,int>mp;\n vector<int>ans;\n int n=nums.size();\n vector<int>temp(n,0);\n \n temp[0]=1;\n \n for(int i=1;i<n;i++){\n temp[i]=nums[i]-nums[i-1];\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n deque<int> q;\n vector<int> ans;\n for(int i = 0 ; i < nums.size() ; i++){\n if(q.empty()){\n q.push_back(nums[i]);\n }else if(q.back()+1 == nums[i]){\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n#define ll long long \n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int>ans;\n deque<int>dq;\n if(k==1){\n return nums;\n }\n int n=nums.size();\n bool flag=true;\n ll sum=0;\n dq.push_back(n... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n deque<int>dq;\n vector<int> v;\n dq.push_front(0);\n\n for(int i=1;i<k-1;i++)\n {\n if(nums[i]-nums[dq.front()]!=1)\n {\n dq.clear();\n }\... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n deque<int>dq;\n vector<int>ans;\n dq.push_front(nums[0]);\n for(int i=1;i<k-1;i++){\n if(dq.size()>0 && nums[i]-dq.front()!=1){\n dq.clea... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int>ans;\n if(k==1)\n return nums;\n priority_queue <int, vector<int>, greater<int> >q; \n priority_queue <int, vector<int>, greater<int>>p;\n int n=nums.size();\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int>ans;\n if(k==1)\n return nums;\n priority_queue <int, vector<int>, greater<int> >q; \n priority_queue <int, vector<int>, greater<int>>p;\n int n=nums.size();\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n vector<int>ans,ans1;\n if(n==1){\n \n if(k==1){\n ans.push_back(nums[0]);\n return ans;\n }\n else {\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> res;\n \n int n = nums.size();\n int itr = 0;\n queue<int> v;\n \n for(; itr < n;){\n while(v.size() < k and itr < n){\n // cout << \"... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> ans;\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n deque<int> q;\n \n for(int i=0;i<n;i++){\n if(q.size()!=0 && q.front()<i-k+1){\n q.pop_front();\n }\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& v, int k) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n vector<int> ans;\n if (k == 1) {\n for (int &x : v) ans.push_back(x);\n return ans;\n }\n \n int n =... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n vector<int> ans;\n deque<pair<int, int>> q;\n \n for (int i = 0; i < n; i++) {\n if (!q.empty() && q.back().first != nums[i] - 1) {\n q.c... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n deque<pair<int,int>>dq;\n for(int i=0;i<k;i++)\n {\n while(!dq.empty() && dq.back().first!=nums[i]-1)\n {\n dq.pop_back();\n }\n dq.push_back... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n deque<pair<int,int>>dq;\n for(int i=0;i<k;i++)\n {\n while(!dq.empty() && dq.back().first!=nums[i]-1)\n {\n dq.pop_back();\n }\n dq.push_back... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size(),c=1;\n if(k==1)return nums;\n vector<int>ans;\n priority_queue<pair<int,int>>q;\n q.push({nums[0],0});\n for(int i=1;i<n;i++){\n if(nums[i]==nums[i-1]... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n deque<int> ok;\n deque<int> temp;\n vector<int> ans;\n \n for(int i=0;i<k;++i){\n if(!temp.empty() && nums[i]!=(temp.back()+1)){\n o... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n\n#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)\n#define ll long long\n#define vi vector<int>\n#define pii pair<int, int>\n\nclass Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if (k ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "\n#include <bits/stdc++.h>\nusing namespace std;\n \n#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)\n#define ll long long\n#define ull unsigned long long\n#define vi vector<int>\n#define vii vector<vector<int>>\n#define vl vector<long long>\n#define vll vector<vector<long ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int> &nums, int k) {\n stack<int> s;\n vector<int> results;\n for (int i : nums) {\n if (!s.empty() && s.top() != i - 1)\n while (!s.empty())\n s.pop();\n\n s.push(i);\n\n if (s.size()>=k)\n results.... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int>ans;\n int n = nums.size();\n deque<int>q;\n for(int i = 0; i < n; i++) {\n if(q.empty() == false) {\n int reff = q.back();\n if(reff + 1 != ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution { \npublic: \n vector<int> resultsArray(vector<int>& nums, int k) { \n vector<int> results; \n double random_var1 = 3.14159;\n string random_var2 = \"random_string\";\n char random_var3 = 'a';\n\n int n = nums.size(); \n bool random_var4 = true;\n... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n vector<int> arr;\n vector<int> dp(n,0);\n queue<int> q;\n for (int i = 1; i < n; ++i) {\n if(nums[i]-nums[i-1]==1){\n dp[i] = dp[i-1] + 1... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& arr, int k) {\n int n = arr.size();\n if(k == 1) return arr;\n vector<int> v, ans;\n int cnt = 0;\n v.push_back(-1);\n for(int i = 1; i< n; i++){\n if(arr[i] - arr[i-1] == 1) cnt++;\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n int count = 1;\n vector<int> ans;\n vector<int> indexcount;\n indexcount.push_back(count);\n for(int i=0;i<n-1;i++)\n {\n // if(nums[i+1]-nu... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> con, vec;\n con.push_back(1);\n int a = 1;\n // Make a prefix array num to for all the consecutive numbers.\n for(int i = 1; i < nums.size(); i++) {\n if(nums[i - ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n int n = nums.size(), count = 0; vector<int> res, maxEle; \n bool in[n+1]; memset(in,false,sizeof(in));\n priority_queue<pair<i... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> answer;\n deque<pair<int,int> > ok;\n int n = nums.size();\n for(int i=0;i<n;i++){\n if(ok.size()){\n int last_element = ok.back().first;\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n vector<int> presum;\n vector<bool> check;\n check.push_back(true);\n for(int i=1;i<nums.size();i++){\n if(nums[i]==(nums[i-1]+1)){\n check.... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int>ans;\n if(k==1){\n return nums;\n }\n deque<pair<int,int>>dq;\n int prev=nums[0]-1;\n int err=0;\n bool ss=true;\n for(int i=0;i<k;i++){\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if(k == 1)\n return nums;\n\n deque<pair<int,int>> dq; // {nums[i], continuity count}\n int i =0, j = 0 , n = nums.size();\n // initial window\n while( j < k){\n /... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n map <int, int> mp;\n vector <int> diff;\n int n = nums.size();\n for (int i=1; i<n; i++) diff.push_back(nums[i] - nums[i-1]);\n for (int i=0; i<k-1; i++){\n mp[diff[i]]++;\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size(),p = k - 1;\n vector<int> d,ans;\n d.push_back(INT_MAX);\n for(int i=1;i<n;i++){\n d.push_back(nums[i]- nums[i-1]);\n }\n map<int,int> m;\n fo... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if(k==1)return nums;\n vector<int> newArr;\n for(int i=1;i<nums.size();i++){\n newArr.push_back(nums[i]-nums[i-1]);\n }\n unordered_map<int,int> mp;\n for(int i=0;i<k-1... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> ans;\n if(nums.size()==1)\n {\n ans.push_back(nums[0]);\n return ans;\n }\n if(k==1)return nums;\n vector<int> temp;\n for(int i=0;i<nums.... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int>diff;\n int n=nums.size();\n for(int i=0;i<n-1;i++){\n diff.push_back(nums[i+1]-nums[i]);\n }\n if(k==1) return nums;\n \n map<int,int>mp;\n se... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> pre;\n int s = 0;\n int prev = nums[0] + 1;\n for (int i = 0; i < nums.size(); ++i){\n if (nums[i] == prev + 1){\n s++;\n }\n prev = ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n vector<int>ans(n-k+1,-1);\n int j=0;\n int mx=0;\n int cnt=1;\n priority_queue<pair<int,int>>pq;\n pq.push({nums[0],0});\n if(k==1)\n {\n... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class SegmentTree {\n vector<int> tree;\n int n;\npublic:\n SegmentTree(vector<int> &arr, int size) {\n n = size;\n tree.resize(4*size + 5, INT_MIN); // Since we need max tree\n\n build(0, 0, size-1, arr);\n }\n\n void build(int ind, int L, int R, vector<int> &arr) {\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n \n int n = nums.size();\n vector<int> pre(n);\n pre[0] = 1;\n for(int i = 1; i < n; i++)\n {\n if(nums[i] > nums[i-1])\n {\n pre[i] = pre[i-1]... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int sz = nums.size();\n vector<int> order(sz);\n vector<long long> sum(sz,0);\n order[0]=1;\n sum[0]=nums[0];\n for(int i=1;i<sz;++i){\n order[i] = nums[i]>nums[i-1] ? ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n=nums.size();\n int count=0;\n \n vector<int>res;\n deque<pair<int,int>>q;\n q.push_back({nums[0],0});\n \n for(int i=1;i<k;i++)\n {\n if(nums... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> ans;\n vector<int> v(nums.size(),0);\n vector<int> mx(nums.size(),0);\n mx[0]=nums[0];\n for(int i=1;i<nums.size();i++){\n if(nums[i-1]>=nums[i]||nums[i]-nums[i-1]... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> result;\n void process(vector<int>& nums, int k, vector<int>& sequence) {\n int left = 0, right = k - 1;\n int count = 0;\n\n for (int i = 0; i <= right; ++i) {\n count += sequence[i];\n }\n\n if (count == k) result... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if(k == 1) return nums;\n vector<int> a;\n vector<int> b;\n b.push_back(0);\n for (int i = 1; i < k; i++)\n b.push_back(1);\n a.push_back(0);\n for (int i = 1; i < nums.size(); i++)\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n queue<int> q;\n vector<int> ans;\n if(k==1) return nums;\n for(int i=nums.size()-1;i>0;i--){\n if(nums[i]-1==nums[i-1]){\n // cout<<nums[i]<<endl;\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n if(k==1){\n return nums;\n }\n int n=nums.size();\n vector<int>ans;\n priority_queue<pair<int,int>>pq;\n for(int i=0;i<k;i++){\n pq.push({nums[i],i});\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n Solution(){\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n }\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int>ans;\n int cnt = 0;//counts how many elements are not in order\n priority_queue<pair<int... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> isitsorted(vector<int> nums, int k){\n if(k==1) return vector<int> (nums.size()-k+1,1); \n int pst=-9999999;\n vector<int> res;\n for(auto i=1; i<nums.size(); i++){\n if(nums[i]-nums[i-1]!=1) pst = i;\n if(i>=k-1){... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& num, int k) {\n int n = num.size();\n vector<int> v(n, 0);\n int prv = num[0]; \n int sum = 0;\n vector<int> mxx(n,0);\n int mxxx = num[0]; \n \n for(int i = 1; i < n; i++) {\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n if(n==1) return {nums[0]};\n if(k==1){\n vector<int> ans;\n for(int n : nums){\n ans.push_back(n);\n }\n return ans;\n... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> ans;\n int n=nums.size();\n vector<int> brr;\n for (int i=1;i<n;i++)\n {\n if (nums[i]-nums[i-1]==1) brr.push_back(1);\n else brr.push_back(0);\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "/*#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"sse4\")*/\n\n#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;\n\n#define fo(i,n) for(int i=0;i<n;i++)\n#define nl ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> ans;\n unordered_map<int, int> mmp;\n\n if (k == 1)\n return nums;\n\n int n = nums.size(), i = 0, j = 0;\n while (i < n)\n {\n if (i < k - 1)\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& arr, int k) {\n int n = arr.size();\n vector<int> ans(n-k+1,-1),dp(n,0);\n unordered_map<int,int> store;\n for(int i=0;i<k;i++){\n if(store.count(arr[i]) == 0)store[arr[i]]=1;\n else store[arr[i]]++;\n }\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n if(n == 1) return {nums[0]};\n if(k == 1) return nums;\n vector<long long> pre;\n int i = 0;\n long long sum = 0;\n while(i<k){\n sum += n... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> arr;\n vector<long long> sum;\n\n int i = 0, j = k - 1;\n long long temp_sum = 0;\n for (int p = 0; p < k; p++) temp_sum += nums[p];\n sum.push_back(temp_sum);\n\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int n = nums.size();\n vector<bool> dives;\n dives.push_back(true);\n for (int i = 1; i < nums.size(); i++) {\n if ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n vector<int> ans(n - k + 1, -1);\n set<int> flips;\n for (int i = 0; i < n - 1; i++) {\n if (nums[i] != nums[i + 1] - 1) {\n flips.insert(i);\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n \n int n = nums.size();\n vector<int> result;\n deque<int> non_consecutive; // List to maintain indices of non-consecutive elements\n priority_queue<pair<int, int>> max_heap; // Max heap to track the... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int cnt=1;\n set<int> s;\n if(k==1) return nums;\n for(int i=0;i<nums.size()-1;i++)\n {\n if(nums[i+1]==nums[i]+1) cnt++;\n else cnt=1;\n if(cnt>=k) s.in... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int size = nums.size();\n vector<int> result;\n set<int> validIndices;\n\n if (k == 1) {\n for (int index = 0; index < size; index++) {\n result.push_back(nums[index]... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class SegmentTree\n{\n vector<int> seg;\n public:\n SegmentTree(int n) {\n seg.resize(4*n+1);\n }\n\n void combine(int ind) { \n\t\tseg[ind] = max(seg[2*ind+1],seg[2*ind+2]); \n\t}\n\n void build(int ind, int low, int high, vector<int>& arr)\n {\n if(low == high)\n {\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\ntypedef long long ll ;\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> ans ;\n deque<ll> dq ;\n vector<ll> vec ;\n int idx = -1 ;\n int n = nums.size() ;\n for(int i = 0 ; i < k ; i++){\n dq.push_back(nu... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "\nvoid built(vector<int>& stree, const vector<int>& nums, int start, int end, int node) {\n if (start == end) {\n stree[node] = nums[start];\n } else {\n int mid = start + (end - start) / 2;\n built(stree, nums, start, mid, 2 * node + 1);\n built(stree, nums, mid + 1, end,... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& arr, int k) {\n if(k==1)\n return arr;\n\n int n = arr.size();\n vector<int> ans;\n\n int prev = 0;\n int value = arr[prev];\n\n map<int, int> done;\n\n for(int i=1; i<n; i++){\n... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n \n \n priority_queue<pair<int, int>> pq;\n \n vector<int> ret;\n \n int n = nums.size();\n \n int last = -k;\n int prev = nums[0] - 1;\n \n... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& arr, int k) {\n vector<int>ans;\n priority_queue<pair<int,int>>pq;\n int i=0,j=0,cnt=0;\n for(int i=0;i<k-1;i++){\n if(arr[j+1]-arr[j]!=1){\n cnt++;\n }\n pq.push... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int i=0,n=nums.size();\n vector<int> ans;\n while(i+k-1<n){\n vector<int> aa;\n aa.push_back(nums[i]);\n i++;\n while(i<n && aa[aa.size()-1]+1==nums[i]){\n ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, long long k) {\n\n if(k==1){\n return nums;\n }\n \n vector<int> ans;\n priority_queue<pair<int,int>> q;\n\n queue<int> q1;\n\n long long currSum=0;\n for(int i=0;i<... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n priority_queue<pair<int,int>>pq;\n if(k==1)\n {\n return nums;\n }\n int n=nums.size();\n vector<int>ans;\n vector<int>diff(n,0);\n diff[0]=1;\n fo... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int> diff;\n vector<int> result;\n \n \n if(k==1)\n {\n return nums;\n }\n \n else if(nums.size()==1)\n {\n return {nums[0... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int n = nums.size();\n vector<int> ans ; \n priority_queue<pair<int, int>> q ; \n vector<int> pre(n, 0);\n for (int i = 1; i < n; i++) {\n if (nums[i] > nums[i - 1] and (nums[... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n vector<int>ans;\n int n = nums.size();\n vector<int>temp(n,1);\n int i=0;\n while(i<n)\n {\n int cnt=0;\n while(i+1<n && nums[i+1]==(nums[i]+1))\n {\n temp[i] = cnt ... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "# define ll long long\n# define ff first\n# define ss second\n# define pb push_back\n# define all(x) (x).begin(), (x).end()\nclass Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n \n \n int n = nums.size();\n vector<int> res(n-k+1);\n vector... |
3,523 | <p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
<p>The <strong>power</strong> of an array is defined as:</p>
<ul>
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>... | 3 | {
"code": "class Solution {\npublic:\n vector<int> resultsArray(vector<int>& nums, int k) {\n int i=0,j=0;\n priority_queue<pair<int,int>>q;\n vector<int>ans;\n vector<bool>b(nums.size(),false);\n vector<int>x(nums.size(),0);\n int mini=INT_MAX;\n for(int i=nums.siz... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.