id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 0 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n //will only stop when there is a higher number than me\n int preind=0;\n long long ans=0;\n for(int i=1;i<nums.size()-1;i++){\n if(nums[i]>nums[preind]){\n ans+=(i-preind)*... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 0 | {
"code": "#define ll long long\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n int j = 0;\n ll ans = 0;\n for(int i = 1; i < nums.size(); i++)\n {\n if(nums[i] >=nums[j])\n {\n ans+=1LL*(i... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 1 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long ans = 0;\n long long i=0, j=1;\n long long n = nums.size();\n\n while(i<j && j<n){\n if(nums[j] > nums[i]){\n ans += (long long) nums[i] * (j-i);\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 1 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int> &nums) {\n long long j = 0;\n long long n = nums.size();\n long long result = 0;\n for (long long i = 1; i < n; i++) {\n if (nums[j] < nums[i]) {\n result += (i - j) * nums[j];\n j = i;\n }\n }\n r... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 2 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) \n {\n long long ans = 0;\n int j = 0;\n int n = nums.size();\n \n for(int i = 0; i < n; i++)\n {\n if(nums[i] > nums[j])\n {\n ans += (long(nums[j]... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(std::vector<int> const& nums) {\n long long score = 0;\n std::size_t previous = 0;\n auto const jump = [&](std::size_t i) noexcept {\n score += static_cast<long long>((i - previous)) * nums[previous];\n pre... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n=nums.size();\n if(n==1)\n return 0;\n int pos[n];\n pos[0]=0;\n int maxi=nums[0];\n for(int i=1;i<n;i++){\n if(nums[i]>maxi){\n maxi=nums[i];\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long n;\n int dp[100002];\n long long solve(int i, vector<int>& nums)\n {\n if (i>=n-1) return 0;\n if (dp[i] != -1) return dp[i];\n long long ans = LONG_MIN;\n for (int k = i+1; k<n; k++)\n {\n if (dp[k] == -1)\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long mx = 0;\n vector<int> targets;\n int cur = 0;\n for(int i=0;i<nums.size()-1;i++){\n if(nums[i]> cur){\n targets.push_back(i);\n cur = nums[i];\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "using ll=long long int;\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& n) {\n \n vector<int> v={0}; //i->j, n[j] is the max in n[0,i]\n ll s=0;\n for(int i=1;i<n.size();i++){\n if( n[i]> n[v.back()]){\n s+=(ll)(n[v.back() ] ) * ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\n\n#define ll long long\nll dp[100001];\npublic:\n long long findMaximumScore(vector<int>& nums) {\n ll ans=0,n=nums.size(),prev=0;\n for(int i=1;i<n;i++)\n {\n if(nums[i]>nums[prev])\n {\n ans+=(ll)(i-prev)*(ll)(nums[prev]);\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) \n {\n int n = nums.size();\n vector<int>idxArray;\n long long ans = 0;\n \n idxArray.push_back(0);\n int idx = 0;\n for(int i=1;i<n-1;i++)\n {\n if(nums[i]>num... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic: \n long long findMaximumScore(vector<int>& nums) {\n long long res = 0;\n stack<pair<long long,long long>> st;\n st.push({nums[0],0});\n for(int i =1;i < nums.size();i++) \n if(st.top().first < nums[i]) {\n pair<long long,long... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<pair<int,int>>s;\n long long ans=0;\n for(int i=0;i<nums.size();i++){\n if(s.empty()){\n s.push({nums[i],i});\n }\n else if(s.top().first<nums[i]){\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "int speedup = []{ios::sync_with_stdio(0); cin.tie(0); return 0;}();\nint idx[100000];\n\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int N = size(nums)-1;\n iota(idx, idx+N, 0);\n sort (idx, idx+N, [&nums](int i, int j) { return nums[j] < nums[i]; }... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n long long res = 0;\n vector<pair<int,int> > ans;\n int maxi = nums[0];\n for(int j=1;j<n;j++){\n if(nums[j] > maxi){\n maxi = nums[j];\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long res = 0;\n int n = nums.size();\n stack<int> mono_increasing_stack;\n for(int i = 0; i < n - 1; ++i) {\n if(mono_increasing_stack.empty() || nums[i] > nums[mono_increasing_stack... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "static int __star = []{\n ios_base::sync_with_stdio(0);\n cin.tie(NULL),cout.tie(NULL);\n return 0;\n}();\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<long long>st;\n int n = nums.size();\n // st.push(-1);\n for(int i=0;i<n;i++... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long res = 0;\n int n = nums.size();\n stack<int> mono_increasing_stack;\n for(int i = 0; i < n - 1; ++i) {\n if(mono_increasing_stack.empty() || nums[i] > nums[mono_increasing_stack... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution{\npublic:\n long long findMaximumScore(vector<int>&nums){\n long long int ans=0,n=nums.size();\n stack<pair<int,int>>st;\n\n st.push({nums[0],0});\n for(int i=1; i<n; i++){\n int ele = st.top().first;\n int ind = st.top().second;\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) \n {\n stack<int> Stack;\n int n = nums.size();\n int i= nums.size()-2;\n while(i>=0)\n {\n while(!Stack.empty() && nums[i] >= nums[Stack.top()])\n Stack.pop();\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n \n // 2 3 1 5\n // 1 3 1 5\n // 4 3 7 3 2\n // 7-> 14\n int N = nums.size();\n stack<int> store;\n \n store.push(N-1)... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n stack<pair<int,int>> st;\n st.push({nums[0],0});\n for(int i=1;i<n;i++){\n if(nums[i] > st.top().first) st.push({nums[i],i});\n }\n\n int max_index = ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<pair<int, int>> st;\n int n=nums.size();\n long long int ans=0;\n st.push({nums[0], 0});\n for(int i=0; i<n-1; i++){\n auto temp=st.top();\n if(nums[i]>temp.first)... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int i,j,k;\n int n = nums.size();\n stack<int> st;\n long long l=0;\n long long score = 0;\n for(i=0;i<n;i++){\n while(!st.empty() && st.top()<nums[i]){\n st.... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long res = 0LL;\n int n = nums.size();\n int next_greater[n];\n next_greater[n - 1] = -1;\n stack<int> st;\n for (int i = n - 1; i >= 0; i--) {\n while(!st.empty() and ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n if(n == 1){\n return 0;\n }\n stack<int>st;\n for(int i=n-2;i>=0;i--){\n while(!st.empty() && nums[st.top()]<nums[i]){\n st.pop();\... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) \n {\n vector<int> next;\n next.push_back(0);\n int prev = nums[0];\n \n for(int i=1;i<nums.size();i++)\n {\n if(nums[i]>=prev)\n {\n next.push_back... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n \n if (n == 1) return 0; // If there's only one element, no score can be calculated.\n if (n == 2) return nums[0]; // If there are two elements, the score is simpl... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<long long >st;\n st.push(nums[0]);\n vector<int>v;\n v.push_back(0);\n for(int i=1;i<nums.size();i++){\n if(nums[i]>st.top()){\n st.push(nums[i]);\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n // unordered_map<long long, unordered_map<long long, long long>> dp;\n // long long f(int idx, int prev, vector<int> &nums){\n // if(idx == nums.size() - 1) return (long long)(idx - prev) * (long long)nums[prev];\n // if(dp.count(idx) && dp[idx].count(prev)) ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n if( n == 1 )\n return 0LL;\n \n \n // hint\n // It can be proven that from each index i, the optimal solution is to jump to the nearest index j > i su... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "#include <bits/stdc++.h>\n\n// building blocks\nusing ll = long long;\nusing db = long double; // or double, if TL is tight\nusing str = string; // yay python!\n\n// pairs\nusing pi = pair<int, int>;\nusing pl = pair<ll, ll>;\nusing pd = pair<db, db>;\n\n#define mp make_pair\n#define f first\n#defi... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n vector<pair<long long,int>> temp;\n int mx = nums[0], n = nums.size();\n temp.push_back({nums[0],0});\n \n for(int i = 1; i < n-1; i++){\n if(nums[i] > mx){\n mx = n... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int cur=nums[0];\n int n=nums.size();\n if(n==1) return 0;\n long long ans=0;\n vector<pair<long long,long long>> vec;\n vec.push_back({nums[0],0});\n for(int i=1;i<n;i++){\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long dfs(const vector<int>& nums, const int pos)\n {\n if(pos + 1 >= size(nums)) return 0;\n auto i = pos + 1;\n for(; i < size(nums); ++i)\n {\n if(nums[i] > nums[pos]) break;\n }\n if(i == size(nums)) --i;\n return 1ll * nums[pos] * (i - pos) +... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define in(n) int n; cin>>n;\n#define inll(n) ll n; cin>>n;\n#define in2(x, y) int x, y; cin>>x>>y;\n#define inll2(x, y) ll x, y; cin>>x>>y;\n#define ins(s) string s; cin>>s;\n#define vi vector<int... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n static long long dp[100007];\n const int n = nums.size();\n dp[n-1] = 0;\n stack<pair<int,int>> st;\n for(int i=n-1; i>=0; i--) {\n //dp[i] = max_{j=i+1 ... n-1} (j-i)*nums[i] + dp... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n static long long dp[100007];\n const int n = nums.size();\n dp[n-1] = 0;\n stack<pair<int,int>> st;\n for(int i=n-1; i>=0; i--) {\n int x = nums[i];\n while(!st.empty() ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n static long long dp[100007];\n const int n = nums.size();\n dp[n-1] = 0;\n stack<pair<int,int>> st;\n for(int i=n-1; i>=0; i--) {\n int x = nums[i];\n while(!st.empty() ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long solve(vector<int>&nums,int ind,int power){\n int n = nums.size();\n if(ind==n-1)return 0;\n if(nums[ind]>power){\n return nums[ind] + solve(nums,ind+1,nums[ind]);\n }\n else{\n return (power)+solve(nums,ind+1,... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n,i,j,k,l;\n n=nums.size();\n long long nxtGr[n+1],score[n+1];\n memset(nxtGr,-1,sizeof(nxtGr));\n memset(score,0,sizeof(score));\n\n stack<int>s;\n s.push(0);\n i=1;... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(std::vector<int>& nums) {\n const int NUM_MAX = 100001;\n std::stack<std::pair<long long, int>> monoStk;\n monoStk.emplace(NUM_MAX, nums.size() - 1);\n for (int i = nums.size() - 2; i >= 0; --i){\n while (!mono... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<pair<int, int>> st;\n for(int i=nums.size()-1; i>=0; i--){\n while(st.size()>0 && st.top().first<nums[i]){\n st.pop();\n }\n st.pus... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<pair<int, int>> st;\n st.push(make_pair(nums.back(), nums.size()-1));\n long long ans = 0;\n for(int ind = nums.size()-2; ind>=0; ind--) {\n pair<int, int> temp = make_pair(nums[ind... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "using ll = long long;\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& a) {\n int n = a.size();\n reverse(a.begin(),a.end()); \n a[0] = 1e9;\n stack<pair<int,int>> st;\n for(int i=0;i<n;i++){\n if(st.empty())\n st.push({a[i],n-1-i});\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n // long long f(int i, vector<int>& nums, vector<long long> &dp){\n // if(i>=nums.size())return 0;\n // if(dp[i]!=-1)return dp[i];\n\n // long long sum=0;\n // for(int j=i+1; j<nums.size(); j++){\n // sum=max(sum,(long long) (j-i)*nums[i]... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long solve(long long i,vector<int>& nums){\n if(i>=nums.size()-1) return 0;\n\n long long ans=0,j=i+1;\n for(;j<nums.size()-1;j++){\n if(nums[j]>nums[i]) break; \n }\n ans=((j-i)*nums[i])+solve(j,nums);\n return ans;\n... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long curr_max = 0, n = nums.size();\n if(n == 1)\n return 0;\n stack<pair<long long, int>> s;\n s.push({nums[n-2], n-2});\n int i = n-3;\n while(i >= 0){\n w... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<pair<int,int>>st;\n int i = 1;\n st.push({nums[0],0});\n while(i < nums.size()){\n if(st.top().first <= nums[i]){\n st.push({nums[i],i});\n }\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n \n long long findMaximumScore(vector<int>& nums) {\n \n deque<pair<long long , long long>> q;\n int n = nums.size();\n \n if(n == 1) return 0;\n \n for(int i = 0 ; i < nums.size()- 1 ; i++){\n \n if(q.e... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\n private:\n long long maxScoreRec(const vector<int>& nums, int idx, int m) {\n int n = nums.size();\n if (idx >= n - 1) {\n return 0;\n }\n\n long long res = 0;\n int j = idx + 1;\n while (j < n && nums[j] <= m) {\n j++... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long n = nums.size();\n stack<long long>s;\n long long next_greater[n];\n memset(next_greater,-1,sizeof(next_greater));\n for(int i=0;i<n;i++)\n {\n if(s.empty() || (!s... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<int> st;\n int n = nums.size();\n \n for(int i=n-1; i>=0; i--){\n while(!st.empty() and nums[i] > nums[st.top()]){\n st.pop();\n }\n st.push(i);... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long n = nums.size();\n\n long long max_idx[n+5];\n\n max_idx[n-1] = n-1;\n\n stack<long long>st;\n\n st.push(n-1);\n\n for(long long i=n-2;i>=0;i--){\n \n whil... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n // just jumping to the biggest number\n vector<pair<int, int>> lis;\n for(int i = 0; i < nums.size(); i++) {\n if (nums.empty()) {\n lis.push_back({nums[i], i});\n } el... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "long long DP[100000];\nint nextGreater[100000];\n\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int length = nums.size();\n stack <pair<int, int>> decreasing;\n for (int i = 0; i != nums.size(); ++i) {\n while (!decreasing.empty() && nums[... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\nlong long dp[100001];\n long long f(int ind ,vector<int>&nums){\n int n=nums.size();\n if(ind==n-1) return 0;\n if(dp[ind]!=-1) return dp[ind];\n\n long long len=0;\n for(int i=ind;i<n-1;i++){\n if(nums[i]>nums[ind]) break;\n len++;\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n\n typedef long long ll;\n ll dp[100000];\n ll solve(int idx, int n, vector<int>& nums){\n if(idx >= n-1){ return 0; }\n if(dp[idx]!=-1) return dp[idx];\n ll i = upper_bound(nums.begin(), nums.end(), nums[idx]) - nums.begin();\n if(i==n){ i--;... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long n=(int)nums.size();\n\n stack<pair<long long,long long>>st;\n\n for(long long i=0;i<n;i++)\n {\n if(st.empty() || nums[i]>st.top().first)\n {\n // while(!st.empty() &&... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long ct = 0;\n int n = nums.size();\n set<pair<int,int>>s;\n s.insert({nums[0],0});\n int prev = nums[0];\n for(int i=1;i<n;i++){\n if(prev<nums[i]){\n p... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n if (n == 1) {\n return 0;\n }\n stack<tuple<int,int,long long>> stk;\n for (int i = n-2; i >= 0; i --) {\n while (stk.size() && get<0>(stk.top()) ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n\n int n=nums.size();\n if(n<3)\n return n==1?0:nums[0];\n \n stack<pair<int,long long>> st;\n long long ans =0;\n\n for(int i=n-2;i>=0;i--)\n {\n while(!st... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n typedef long long ll;\n ll dp[100001];\n ll f(ll ind,ll n,vector<int> &nums){\n if(ind >= nums.size())\n return 0;\n \n if(dp[ind] != -1)\n return dp[ind];\n \n ll score=0;\n ll maxscore=0;\n \n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n typedef long long int ll;\n long long findMaximumScore(vector<int>& nums) {\n int n=nums.size();\n stack<pair<ll,int>>st;\n for(int i=n-1;i>=0;i--){\n while(!st.empty() && nums[i]>st.top().first){\n st.pop();\n }\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n=nums.size();\n long long ans=0;\n stack<pair<long long, int>>s;\n // priority_queue<pair<long long, int>>pq;\n for(int i=n-1;i>=0;i--){\n long long c=(long long)(n-1-i)*nums[... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n stack<pair<long long,long long>> stk{};\n stk.push({n-1,0});\n for(int i = n-2; i>=0; --i){\n while(!stk.empty() && nums[i]>nums[stk.top().first]){\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long solve(vector<int>& nums, long long curr, long long next) {\n long long n = nums.size();\n long long jumpscore = 0;\n if (next >= n)\n return 0;\n\n\n if (nums[next] > nums[curr] || next == n - 1) {\n return ju... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long f(long long i, vector<int> &nums, vector<long long> &dp){\n long long n = nums.size();\n if(i>= n){\n return 0;\n }\n if(i == n-1){\n return 0;\n }\n if(dp[i] != -1){\n return dp[i];\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n map<int,int> m;\n int j=0;\n int mx=nums[0];\n int n=nums.size();\n for(int i=0;i<n-1;i++){\n if(nums[i]>mx){\n m[j]=i;\n mx=nums[i];\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "#define ll long long\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n map<int,int> m;\n int curr = nums[0];\n for(int i=1;i<nums.size();i++) {\n m[curr]++;\n if(curr<nums[i]) \n curr = nums[i];\n } \n l... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<pair<int,int>> stk,st;\n int n=nums.size();\n long long result=0;\n int maxind=n-1;\n for(int i=n-1;i>=0;i--){\n while(!stk.empty() and stk.top().first<nums[i]){\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n stack<pair<int,int>> stk,st;\n int n=nums.size();\n long long result=0;\n int maxind=n-1;\n for(int i=n-1;i>=0;i--){\n while(!stk.empty() and stk.top().first<nums[i]){\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "#define ll long long\n\nclass Solution {\npublic:\n ll findMaximumScore(vector<int>& nums) {\n vector<vector<int>> v;\n int mx = -1;\n for ( int i = 0; i < nums.size(); i++ ) {\n if ( nums[i] > mx ) {\n v.push_back({nums[i], i});\n mx = nums[... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long func(vector<int>& arr, long long ind, int n) {\n if (ind >= n - 1) return 0;\n\n long long int i=ind+1;\n while(i<n &&arr[i]<=arr[ind])i++;\n\n long long var=0 ;\n if(i<n)var= arr[ind] * (i - ind);\n else var=arr... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long func(vector<int>& arr, long long ind, int n) {\n if (ind >= n - 1) return 0;\n\n long long int i=ind+1;\n while(i<n &&arr[i]<=arr[ind])i++;\n\n long long var=0 ;\n if(i<n)var= arr[ind] * (i - ind);\n else var=arr... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long func(vector<int>& arr, long long ind, int n) {\n if (ind >= n - 1) return 0;\n\n long long int i=ind+1;\n while(i<n &&arr[i]<=arr[ind])i++;\n\n long long var=0 ;\n if(i<n)var= arr[ind] * (i - ind);\n else var=arr... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n\n long long helper(vector<int> v,int n) {\n long long res = 0,prev = 0;\n\n for(int i=1;i<n;i++) {\n if(v[prev] <= v[i] || (i == (n-1))) {\n res += (i-prev) * v[prev];\n prev = i;\n }\n }\n\n retu... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n std::vector<int> dp(n, 0);\n\n long long cur = nums[0];\n long long pos = 0;\n long long ans = 0;\n for (int i = 1; i < n; ++i) {\n if (nums[i] > cur)... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n vector<int> prefix(n, -1);\n int val = nums[0];\n for(int i=1; i<n-1; i++) {\n prefix[i] = val;\n if(nums[i]>val) val = nums[i];\n }\n pref... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n\n long long solve(vector<int>& nums, int idx, vector<long long>& dp){\n if(idx == 0) return 0;\n if(dp[idx] != -1) return dp[idx];\n long long maxi = LLONG_MIN;\n for(int i=idx-1; i>=0; i--){\n long long temp = (1LL*nums[i]*(idx-i)) + so... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "static int F[100'002][18];\nstatic int M[100'001];\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n long long result = 0;\n int const N = nums.size();\n memset(M, 0, sizeof(M));\n for (int i = N - 1; i >= 0; --i)\n M[nums[i]] = i;\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "#define ll long long\n#define pb push_back\nclass Solution {\n vector<int>nextGret(vector<int>&nums){\n int n = nums.size();\n \n vector<int>st;\n vector<int>ans(n);\n st.pb(-1);\n for(int i=n-1;i>=0;i--){\n while(!st.empty() && st.back()!=-1 && nums[... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n template<typename T, typename T_compare>\n vector<int> closest_right(const vector<T> &values, T_compare &&compare) {\n int n = values.size();\n vector<int> closest(n);\n vector<int> stack;\n \n for (int i = n - 1; i >= 0; i--) {\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n // Greedy, create a stack to store the increasing numbers along with index\n long long score = 0, size = nums.size();\n stack <pair <long long, long long>> st, st1;\n for(int i = 0; i<nums.size(); i... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n vector<int> res(n,n-1);\n\n vector<int> stk;\n \n for (int i = n - 1; i >= 0; i--) {\n while (!stk.empty() && nums[stk.back()] <= nums[i]) {\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long dp[100001];\n long long dfs(int i, vector<int> &nums){\n if(i==0) return 0;\n if(dp[i]!=-1) return dp[i];\n long long sol=LONG_MIN;\n for(int j=i-1;j>=0;j--){\n sol=max(sol, 1ll*(i-j)*nums[j]+dfs(j, nums));\n }\n ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 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 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 lon... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "#define ll long long\nclass Solution {\npublic:\n long long findMaximumScore(vector<int>& nums) {\n int n = nums.size();\n vector<int> nge(n);\n nge[n-1]=n-1;\n stack<pair<int,int>> stk;\n stk.push({nums[n-1],n-1});\n for(int i=n-2;i>=0;i--){\n if(stk... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n \n long long findMaximumScore(vector<int>& nums) {\n if(nums.size() == 1){\n return 0;\n }\n stack<int> st;\n st.push(nums[0]);\n for(int i = 1; i < nums.size() - 1; i++){\n if(nums[i] > st.top() && i != nums.size() ... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n\n long long solve(int i,vector<int>&nums,vector<int>&dp){\n if(i==nums.size()-1){\n return 0;\n }\n\n \n\n long long res=INT_MIN;\n\n for(int j=i+1;j<nums.size();j++){\n if(nums[j]>nums[i]){\n res=(long long)((long long)(j-i)*... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long solve(int ind,vector<int> &nums, vector<int> &bestRight){\n if(ind==nums.size()-1){\n return 0;\n }\n\n int nextspot = bestRight[ind];\n int diff = nextspot - ind;\n return (long long)diff*nums[ind] + solve(nextspot,nums... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long solve(int ind,int n,vector<int>&nums,vector<long long>&dp){\n if(ind>=n) return 0 ; \n if(dp[ind]!=-1) return dp[ind]; \n long long ans = 0 ; \n for(int k=ind+1;k<n;k++){\n ans=max(ans,1ll*(k-ind)*nums[ind] + solve(k,n,nums,dp)... |
3,528 | <p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
<p>Your goal is to start at index <code>0</code> and reach index <code>n - 1</code>. You can only jump to indices <strong>greater</strong> than your current index.</p>
<p>The score for a jump from index <code>i</code> to index <code>j</... | 3 | {
"code": "class Solution {\npublic:\n long long findMaximumScore(vector<int>& a) {\n int n = a.size();\n vector<long long>pref(n + 1,0);\n pref[1] = a[0];\n int mx = a[0];\n long long sum = 0;\n for(int i = 1;i<n;i++){\n sum += mx;\n pref[i] = sum;... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n int maxMoves(int kx, int ky, vector<vector<int>>& pos) {\n static constexpr int r = 50, c = 50, n = r * c, maxm = 15, maxs = 1 << 15 | 1;\n static int dis[r + 1][c + 1], w[maxm][maxm], f[maxm][maxs];\n auto getDis = [&](int sx, int sy) {\n int ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n int dist[15][15];\n int dp[32800][15] = {};\n\n int help(int idx, int n, int mask) {\n if (!mask)\n return 0;\n\n if (dp[mask][idx])\n return dp[mask][idx] - 1;\n\n int res, c = bitset<16>(mask).count();\n\n if ((n - c) ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "static char DD[50][50][50][50];\nstatic char D[50][50];\nstatic bool isInit = false;\nstatic void init()\n{\n if (!isInit)\n {\n isInit = true;\n array dx = { -2, -2, -1, -1, 1, 1, 2, 2 };\n array dy = { -1, 1, -2, 2, -2, 2, -1, 1 };\n memset(DD, 100, sizeof(DD));\n ... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n static constexpr int size {50};\n static constexpr array<array<int, size>, size> metric {{\n {0,3,2,3,2,3,4,5,4,5,6,7,6,7,8,9,8,9,10,11,10,11,12,13,12,13,14,15,14,15,16,17,16,17,18,19,18,19,20,21,20,21,22,23,22,23,24,25,24,25},\n {3,2,1,2,3,4,3,4,5,6,5,6,7,8,... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "class Solution {\npublic:\n int minDistance(int x,int y,int x1,int y1){\n int _x=abs(x-x1),_y=abs(y-y1);\n if(_x<_y){\n swap(_x,_y);\n }\n if(_x==1 && _y==0)return 3;\n else if(_x==2 && _y==2)return 4;\n else if(_x==1 && _y==1 && (((x==0||x==49)&&(y==0||y==49))... |
3,560 | <p>There is a <code>50 x 50</code> chessboard with <strong>one</strong> knight and some pawns on it. You are given two integers <code>kx</code> and <code>ky</code> where <code>(kx, ky)</code> denotes the position of the knight, and a 2D array <code>positions</code> where <code>positions[i] = [x<sub>i</sub>, y<sub>i</su... | 0 | {
"code": "#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"inline\")\n#include<bits/stdc++.h>\nusing namespace std;\ntemplate<class S, class T> inline S chmin(S &a, T b){\n if(a>b){\n a=b;\n }\n return a;\n}\ntemplate<class S, class T> inline S chmax(S &a, T b){\n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.