Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Interview Problems on DP
  • Practice DP
  • MCQs on DP
  • Tutorial on Dynamic Programming
  • Optimal Substructure
  • Overlapping Subproblem
  • Memoization
  • Tabulation
  • Tabulation vs Memoization
  • 0/1 Knapsack
  • Unbounded Knapsack
  • Subset Sum
  • LCS
  • LIS
  • Coin Change
  • Word Break
  • Egg Dropping Puzzle
  • Matrix Chain Multiplication
  • Palindrome Partitioning
  • DP on Arrays
  • DP with Bitmasking
  • Digit DP
  • DP on Trees
  • DP on Graph
Open In App
Next Article:
Printing Maximum Sum Increasing Subsequence
Next article icon

Maximum Sum Increasing Subsequence

Last Updated : 02 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
Try it on GfG Practice
redirect icon

Given an array arr[] of n positive integers. The task is to find the sum of the maximum sum subsequence of the given array such that the integers in the subsequence are sorted in strictly increasing order.

Examples:

Input: arr[] = [1, 101, 2, 3, 100]
Output: 106
Explanation: The maximum sum of a increasing sequence is obtained from [1, 2, 3, 100].

Input: arr[] = [4, 1, 2, 3]
Output: 6
Explanation: The maximum sum of a increasing sequence is obtained from [1, 2, 3].

Table of Content

  • [Naive Approach] Using Recursion – O(2^n) Time and O(n) Space
  • [Better Approach 1] Using Top-Down DP (Memoization) – O(n^2) Time and O(n) Space
  • [Better Approach 2] Using Bottom-Up DP (Tabulation) – O(n^2) Time and O(n) Space
  • [Expected Approach] Using Dynamic Programming and Greedy – O(n log(n)) time and O(n) space

[Naive Approach] Using Recursion – O(2^n) Time and O(n) Space

This problem is a variation of the standard Longest Increasing Subsequence (LIS) problem. In this problem, we will consider the sum of subsequence instead of its length.

The idea is to solve the problem recursively by considering every index i in the array as a potential end of an increasing subsequence. For each index i, initialize the maximum sum subsequence ending at i to arr[i]. Then, for every previous index j (0 ≤ j < i), check if arr[j] < arr[i]. If this condition is met, recursively compute the maximum sum subsequence ending at j and update the result for i by taking the maximum of its current value and arr[i] + maxSum(j). Finally, return the maximum value obtained across all indices as the result.

C++
// C++ program to find maximum // Sum Increasing Subsequence #include <bits/stdc++.h> using namespace std;  // Recursive function which finds the  // maximum sum increasing Subsequence // ending at index i. int maxSumRecur(int i, vector<int> &arr) {          int ans = arr[i];          // Compute values for all      // j in range (0, i-1)     for (int j= i-1; j>=0; j--) {         if (arr[j]<arr[i]) {             ans = max(ans, arr[i]+maxSumRecur(j, arr));         }     }          return ans; }  int maxSumIS(vector<int> &arr) {     int ans = 0;          // Compute maximum sum for each      // index and compare it with ans.     for (int i=0; i<arr.size(); i++) {         ans = max(ans, maxSumRecur(i, arr));     }          return ans; }  int main() {     vector<int> arr = {1, 101, 2, 3, 100};     cout << maxSumIS(arr);      return 0; } 
Java
// Java program to find maximum // Sum Increasing Subsequence  class GfG {      // Recursive function which finds the      // maximum sum increasing Subsequence     // ending at index i.     static int maxSumRecur(int i, int[] arr) {         int ans = arr[i];          // Compute values for all          // j in range (0, i-1)         for (int j = i - 1; j >= 0; j--) {             if (arr[j] < arr[i]) {                 ans = Math.max(ans, arr[i] + maxSumRecur(j, arr));             }         }          return ans;     }      static int maxSumIS(int[] arr) {         int ans = 0;          // Compute maximum sum for each          // index and compare it with ans.         for (int i = 0; i < arr.length; i++) {             ans = Math.max(ans, maxSumRecur(i, arr));         }          return ans;     }      public static void main(String[] args) {         int[] arr = {1, 101, 2, 3, 100};         System.out.println(maxSumIS(arr));     } } 
Python
# Python program to find maximum # Sum Increasing Subsequence  # Recursive function which finds the  # maximum sum increasing Subsequence # ending at index i. def maxSumRecur(i, arr):     ans = arr[i]      # Compute values for all      # j in range (0, i-1)     for j in range(i - 1, -1, -1):         if arr[j] < arr[i]:             ans = max(ans, arr[i] + maxSumRecur(j, arr))      return ans  def maxSumIS(arr):     ans = 0      # Compute maximum sum for each      # index and compare it with ans.     for i in range(len(arr)):         ans = max(ans, maxSumRecur(i, arr))      return ans  if __name__ == "__main__":     arr = [1, 101, 2, 3, 100]     print(maxSumIS(arr)) 
C#
// C# program to find maximum // Sum Increasing Subsequence  using System;  class GfG {      // Recursive function which finds the      // maximum sum increasing Subsequence     // ending at index i.     static int maxSumRecur(int i, int[] arr) {         int ans = arr[i];          // Compute values for all          // j in range (0, i-1)         for (int j = i - 1; j >= 0; j--) {             if (arr[j] < arr[i]) {                 ans = Math.Max(ans, arr[i] + maxSumRecur(j, arr));             }         }          return ans;     }      static int maxSumIS(int[] arr) {         int ans = 0;          // Compute maximum sum for each          // index and compare it with ans.         for (int i = 0; i < arr.Length; i++) {             ans = Math.Max(ans, maxSumRecur(i, arr));         }          return ans;     }      static void Main(string[] args) {         int[] arr = {1, 101, 2, 3, 100};         Console.WriteLine(maxSumIS(arr));     } } 
JavaScript
// JavaScript program to find maximum // Sum Increasing Subsequence  // Recursive function which finds the  // maximum sum increasing Subsequence // ending at index i. function maxSumRecur(i, arr) {     let ans = arr[i];      // Compute values for all      // j in range (0, i-1)     for (let j = i - 1; j >= 0; j--) {         if (arr[j] < arr[i]) {             ans = Math.max(ans, arr[i] + maxSumRecur(j, arr));         }     }      return ans; }  function maxSumIS(arr) {     let ans = 0;      // Compute maximum sum for each      // index and compare it with ans.     for (let i = 0; i < arr.length; i++) {         ans = Math.max(ans, maxSumRecur(i, arr));     }      return ans; }  const arr = [1, 101, 2, 3, 100]; console.log(maxSumIS(arr)); 

Output
106

[Better Approach 1] Using Top-Down DP (Memoization) – O(n^2) Time and O(n) Space

If we notice carefully, we can observe that the above recursive solution holds the following two properties of Dynamic Programming:

1. Optimal Substructure: The maximum sum increasing subsequence ending at index i, i.e., maxSum(i), depends on the optimal solutions of the subproblems maxSum(j) where 0 <= j < i and arr[j]<arr[i]. By finding the maximum value in these optimal substructures, we can efficiently calculate the maximum sum increasing subsequence at index i.

2. Overlapping Subproblems: While applying a recursive approach in this problem, we notice that certain subproblems are computed multiple times.

  • There is one parameter, i that changes in the recursive solution. So we create a 1D array of size n for memoization.
  • We initialize this array as -1 to indicate nothing is computed initially.
  • Now we modify our recursive solution to first check if the value is -1, then only make recursive calls. This way, we avoid re-computations of the same subproblems.
C++
// C++ program to find maximum // Sum Increasing Subsequence #include <bits/stdc++.h> using namespace std;  // Recursive function which finds the  // maximum sum increasing Subsequence // ending at index i. int maxSumRecur(int i, vector<int> &arr, vector<int> &memo) {          // If value is computed,     // return it.     if (memo[i]!=-1) return memo[i];          int ans = arr[i];          // Compute values for all      // j in range (0, i-1)     for (int j = i-1; j >= 0; j--) {         if (arr[j]<arr[i]) {             ans = max(ans, arr[i]+maxSumRecur(j, arr, memo));         }     }          return memo[i] = ans; }  int maxSumIS(vector<int> &arr) {     int ans = 0;          vector<int> memo(arr.size(), -1);          // Compute maximum sum for each      // index and compare it with ans.     for (int i=0; i<arr.size(); i++) {         ans = max(ans, maxSumRecur(i, arr, memo));     }          return ans; }  int main() {     vector<int> arr = {1, 101, 2, 3, 100};     cout << maxSumIS(arr);      return 0; } 
Java
// Java program to find maximum // Sum Increasing Subsequence  import java.util.Arrays;  class GfG {      // Recursive function which finds the      // maximum sum increasing Subsequence     // ending at index i.     static int maxSumRecur(int i, int[] arr, int[] memo) {                  // If value is computed,         // return it.         if (memo[i] != -1) return memo[i];                  int ans = arr[i];                  // Compute values for all          // j in range (0, i-1)         for (int j = i - 1; j >= 0; j--) {             if (arr[j] < arr[i]) {                 ans = Math.max(ans, arr[i] + maxSumRecur(j, arr, memo));             }         }                  return memo[i] = ans;     }      static int maxSumIS(int[] arr) {         int ans = 0;                  int[] memo = new int[arr.length];         Arrays.fill(memo, -1);                  // Compute maximum sum for each          // index and compare it with ans.         for (int i = 0; i < arr.length; i++) {             ans = Math.max(ans, maxSumRecur(i, arr, memo));         }                  return ans;     }      public static void main(String[] args) {         int[] arr = {1, 101, 2, 3, 100};         System.out.println(maxSumIS(arr));     } } 
Python
# Python program to find maximum # Sum Increasing Subsequence  # Recursive function which finds the  # maximum sum increasing Subsequence # ending at index i. def maxSumRecur(i, arr, memo):          # If value is computed,     # return it.     if memo[i] != -1:         return memo[i]          ans = arr[i]          # Compute values for all      # j in range (0, i-1)     for j in range(i - 1, -1, -1):         if arr[j] < arr[i]:             ans = max(ans, arr[i] + maxSumRecur(j, arr, memo))          memo[i] = ans     return ans  def maxSumIS(arr):     ans = 0     memo = [-1] * len(arr)          # Compute maximum sum for each      # index and compare it with ans.     for i in range(len(arr)):         ans = max(ans, maxSumRecur(i, arr, memo))          return ans  if __name__ == "__main__":     arr = [1, 101, 2, 3, 100]     print(maxSumIS(arr)) 
C#
// C# program to find maximum // Sum Increasing Subsequence  using System;  class GfG {      // Recursive function which finds the      // maximum sum increasing Subsequence     // ending at index i.     static int maxSumRecur(int i, int[] arr, int[] memo) {                  // If value is computed,         // return it.         if (memo[i] != -1) return memo[i];                  int ans = arr[i];                  // Compute values for all          // j in range (0, i-1)         for (int j = i - 1; j >= 0; j--) {             if (arr[j] < arr[i]) {                 ans = Math.Max(ans, arr[i] + maxSumRecur(j, arr, memo));             }         }                  return memo[i] = ans;     }      static int maxSumIS(int[] arr) {         int ans = 0;                  int[] memo = new int[arr.Length];         Array.Fill(memo, -1);                  // Compute maximum sum for each          // index and compare it with ans.         for (int i = 0; i < arr.Length; i++) {             ans = Math.Max(ans, maxSumRecur(i, arr, memo));         }                  return ans;     }      static void Main(string[] args) {         int[] arr = {1, 101, 2, 3, 100};         Console.WriteLine(maxSumIS(arr));     } } 
JavaScript
// JavaScript program to find maximum // Sum Increasing Subsequence  // Recursive function which finds the  // maximum sum increasing Subsequence // ending at index i. function maxSumRecur(i, arr, memo) {          // If value is computed,     // return it.     if (memo[i] !== -1) return memo[i];          let ans = arr[i];          // Compute values for all      // j in range (0, i-1)     for (let j = i - 1; j >= 0; j--) {         if (arr[j] < arr[i]) {             ans = Math.max(ans, arr[i] + maxSumRecur(j, arr, memo));         }     }          memo[i] = ans;     return ans; }  function maxSumIS(arr) {     let ans = 0;     let memo = Array(arr.length).fill(-1);          // Compute maximum sum for each      // index and compare it with ans.     for (let i = 0; i < arr.length; i++) {         ans = Math.max(ans, maxSumRecur(i, arr, memo));     }          return ans; }  const arr = [1, 101, 2, 3, 100]; console.log(maxSumIS(arr)); 

Output
106

[Better Approach 2] Using Bottom-Up DP (Tabulation) – O(n^2) Time and O(n) Space

The approach is similar to the previous one. just instead of breaking down the problem recursively, we iteratively build up the solution by calculating in bottom-up manner. The idea is to create a 1-D array. Then fill the values using dp[i] = max(arr[i] + dp[j]) for 0 <= j < i and arr[j]<arr[i].

C++
// C++ program to find maximum // Sum Increasing Subsequence #include <bits/stdc++.h> using namespace std;  int maxSumIS(vector<int> &arr) {     int ans = 0;          vector<int> dp(arr.size());          // Compute maximum sum for each      // index and compare it with ans.     for (int i=0; i<arr.size(); i++) {         dp[i] = arr[i];                  for (int j=0; j<i; j++) {             if (arr[j]<arr[i]) {                 dp[i] = max(dp[i], arr[i]+dp[j]);             }         }                  ans = max(ans, dp[i]);     }          return ans; }  int main() {     vector<int> arr = {1, 101, 2, 3, 100};     cout << maxSumIS(arr);      return 0; } 
Java
// Java program to find maximum // Sum Increasing Subsequence  import java.util.Arrays;  class GfG {      static int maxSumIS(int[] arr) {         int ans = 0;                  int[] dp = new int[arr.length];                  // Compute maximum sum for each          // index and compare it with ans.         for (int i = 0; i < arr.length; i++) {             dp[i] = arr[i];                          for (int j = 0; j < i; j++) {                 if (arr[j] < arr[i]) {                     dp[i] = Math.max(dp[i], arr[i] + dp[j]);                 }             }                          ans = Math.max(ans, dp[i]);         }                  return ans;     }      public static void main(String[] args) {         int[] arr = {1, 101, 2, 3, 100};         System.out.println(maxSumIS(arr));     } } 
Python
# Python program to find maximum # Sum Increasing Subsequence  def maxSumIS(arr):     ans = 0          dp = [0] * len(arr)          # Compute maximum sum for each      # index and compare it with ans.     for i in range(len(arr)):         dp[i] = arr[i]                  for j in range(i):             if arr[j] < arr[i]:                 dp[i] = max(dp[i], arr[i] + dp[j])                  ans = max(ans, dp[i])          return ans  if __name__ == "__main__":     arr = [1, 101, 2, 3, 100]     print(maxSumIS(arr)) 
C#
// C# program to find maximum // Sum Increasing Subsequence  using System;  class GfG {      static int maxSumIS(int[] arr) {         int ans = 0;                  int[] dp = new int[arr.Length];                  // Compute maximum sum for each          // index and compare it with ans.         for (int i = 0; i < arr.Length; i++) {             dp[i] = arr[i];                          for (int j = 0; j < i; j++) {                 if (arr[j] < arr[i]) {                     dp[i] = Math.Max(dp[i], arr[i] + dp[j]);                 }             }                          ans = Math.Max(ans, dp[i]);         }                  return ans;     }      static void Main(string[] args) {         int[] arr = {1, 101, 2, 3, 100};         Console.WriteLine(maxSumIS(arr));     } } 
JavaScript
// JavaScript program to find maximum // Sum Increasing Subsequence  function maxSumIS(arr) {     let ans = 0;          let dp = new Array(arr.length);          // Compute maximum sum for each      // index and compare it with ans.     for (let i = 0; i < arr.length; i++) {         dp[i] = arr[i];                  for (let j = 0; j < i; j++) {             if (arr[j] < arr[i]) {                 dp[i] = Math.max(dp[i], arr[i] + dp[j]);             }         }                  ans = Math.max(ans, dp[i]);     }          return ans; }  const arr = [1, 101, 2, 3, 100]; console.log(maxSumIS(arr)); 

Output
106

[Expected Approach] Using Dynamic Programming and Greedy – O(n log(n)) time and O(n) space

This approach combines dynamic programming and a greedy strategy to efficiently find the maximum sum of an increasing subsequence in an array. The key idea is based on Longest Increasing Subsequence (or LIS) using Binary Search. Unlike LIS, here we need to compare sums, so we cannot do binary search over the array. We use a Tree Map or Similar Structure to keep sums corresponding to different values. We build the solution incrementally and prune invalid subsequences to ensure that only the most promising candidates are kept in the tree map.

  1. Start from the End:
    • Traverse the array from the last element to the first.
    • For each element, consider the best subsequences that can come after it.
  2. Dynamic Programming with Greedy Strategy:
    • Use dynamic programming to build the solution incrementally.
    • For each element, calculate the best sum of an increasing subsequence that can start from it.
  3. Store Maximum Subsequence Sum:
    • Use a map (or similar structure) to store the maximum sum of subsequences for each element.
    • The key is the element, and the value is the maximum sum possible for subsequences starting from that element.
  4. Greedy Pruning:
    • As you traverse the array, discard subsequences that cannot contribute to the best result.
    • Remove any subsequences whose sum is less than the current element’s potential sum.
  5. Maintain Increasing Order:
    • Ensure subsequences are strictly increasing by only considering elements greater than the current element for the next subsequence.
  6. Efficient Updates and Lookups:
    • The map allows quick lookups to find the best subsequences for the next element.
    • Update the map as you encounter better subsequences that include the current element.
C++
#include <iostream> #include <map> #include <vector> using namespace std;  int maxSumIS(vector<int> &arr) {     int n = (int)arr.size();      // Map to store the maximum subsequence sum for each element     map<int, int> mp;     int answer = 0;      // Traverse the array from end to start     for (int i = n - 1; i >= 0; i--)     {         int val = arr[i];          auto it = mp.upper_bound(val);          int bestNext = 0;         if (it != mp.end())         {             bestNext = it->second;         }          int temp = val + bestNext;          answer = max(answer, temp);          // Find and remove all subsequences         // that cannot contribute to the best result         auto removeIt = mp.lower_bound(val);          if (removeIt != mp.begin())         {             auto jt = removeIt;             --jt;             while (true)             {                 // Prune invalid subsequences by checking                 // if they cannot contribute to a better result                 if (jt->first < val && jt->second <= temp)                 {                     if (jt == mp.begin())                     {                         mp.erase(jt);                         break;                     }                     else                     {                         auto temp = jt;                         --jt;                         mp.erase(temp);                     }                 }                 else                 {                     break;                 }             }         }          // Insert the current element and its best subsequence sum into the map         auto exist = mp.lower_bound(val);         if (exist == mp.end() || exist->first != val)         {             // If element doesn't exist, insert it             mp.insert({val, temp});         }         else         {             if (exist->second < temp)             {                 // If a better subsequence sum exists, update it                 exist->second = temp;             }         }     }      return answer; }  int main() {     vector<int> arr = {1, 101, 2, 3, 100};     cout << maxSumIS(arr) << "\n";      return 0; } 
Java
import java.util.*;  public class GfG{     public static int maxSumIS(int[] arr)     {         int n = arr.length;          // Map to store the maximum subsequence sum for each         // element         TreeMap<Integer, Integer> mp = new TreeMap<>();         int answer = 0;          // Traverse the array from end to start         for (int i = n - 1; i >= 0; i--) {             int val = arr[i];              Integer bestNext = mp.higherKey(val);             int bestValue                 = (bestNext != null) ? mp.get(bestNext) : 0;              int temp = val + bestValue;              answer = Math.max(answer, temp);              // Find and remove all subsequences             // that cannot contribute to the best result             Iterator<Map.Entry<Integer, Integer> > removeIt                 = mp.tailMap(val, false)                       .entrySet()                       .iterator();             while (removeIt.hasNext()) {                 Map.Entry<Integer, Integer> entry                     = removeIt.next();                 if (entry.getValue() <= temp) {                     removeIt.remove();                 }                 else {                     break;                 }             }              // Insert the current element and its best             // subsequence sum into the map             if (!mp.containsKey(val)) {                 mp.put(val, temp);             }             else {                 if (mp.get(val) < temp) {                     mp.put(val, temp);                 }             }         }          return answer;     }      public static void main(String[] args)     {         int[] arr = { 1, 101, 2, 3, 100 };         System.out.println(maxSumIS(arr));     } } 
Python
def max_sum_is(arr):     n = len(arr)      # Map to store the maximum subsequence sum for each element     mp = {}     answer = 0      # Traverse the array from end to start     for i in range(n - 1, -1, -1):         val = arr[i]          best_next = max((k for k in mp.keys() if k > val), default=None)         best_value = mp[best_next] if best_next is not None else 0          temp = val + best_value          answer = max(answer, temp)          # Find and remove all subsequences         # that cannot contribute to the best result         keys_to_remove = [k for k in mp if k >= val]         for k in keys_to_remove:             if mp[k] <= temp:                 del mp[k]             else:                 break          # Insert the current element and its best subsequence sum into the map         if val not in mp:             mp[val] = temp         else:             if mp[val] < temp:                 mp[val] = temp      return answer   arr = [1, 101, 2, 3, 100] print(max_sum_is(arr)) 
C#
using System; using System.Collections.Generic;  class GfG{     public static int MaxSumIS(int[] arr)     {         int n = arr.Length;          // Map to store the maximum subsequence sum for each         // element         SortedDictionary<int, int> mp             = new SortedDictionary<int, int>();         int answer = 0;          // Traverse the array from end to start         for (int i = n - 1; i >= 0; i--) {             int val = arr[i];              int bestNext = 0;             foreach(var key in mp.Keys)             {                 if (key > val) {                     bestNext = mp[key];                     break;                 }             }              int temp = val + bestNext;              answer = Math.Max(answer, temp);              // Find and remove all subsequences             // that cannot contribute to the best result             var keysToRemove = new List<int>();             foreach(var key in mp.Keys)             {                 if (key >= val)                     break;                 if (mp[key] <= temp) {                     keysToRemove.Add(key);                 }                 else {                     break;                 }             }             foreach(var key in keysToRemove)             {                 mp.Remove(key);             }              // Insert the current element and its best             // subsequence sum into the map             if (!mp.ContainsKey(val)) {                 mp[val] = temp;             }             else {                 if (mp[val] < temp) {                     mp[val] = temp;                 }             }         }          return answer;     }      public static void Main()     {         int[] arr = { 1, 101, 2, 3, 100 };         Console.WriteLine(MaxSumIS(arr));     } } 
JavaScript
function maxSumIS(arr) {     let n = arr.length;      // Map to store the maximum subsequence sum for each     // element     let mp = new Map();     let answer = 0;      // Traverse the array from end to start     for (let i = n - 1; i >= 0; i--) {         let val = arr[i];          let bestNext = 0;         for (let [key, value] of mp) {             if (key > val) {                 bestNext = value;                 break;             }         }          let temp = val + bestNext;          answer = Math.max(answer, temp);          // Find and remove all subsequences         // that cannot contribute to the best result         for (let [key, value] of mp) {             if (key >= val)                 break;             if (value <= temp) {                 mp.delete(key);             }             else {                 break;             }         }          // Insert the current element and its best         // subsequence sum into the map         if (!mp.has(val)) {             mp.set(val, temp);         }         else {             if (mp.get(val) < temp) {                 mp.set(val, temp);             }         }     }      return answer; }  let arr = [ 1, 101, 2, 3, 100 ]; console.log(maxSumIS(arr)); 

Output
106 


Next Article
Printing Maximum Sum Increasing Subsequence
author
kartik
Improve
Article Tags :
  • Arrays
  • DSA
  • Dynamic Programming
  • Amazon
  • LIS
  • Morgan Stanley
Practice Tags :
  • Amazon
  • Morgan Stanley
  • Arrays
  • Dynamic Programming

Similar Reads

  • Maximum Sum Decreasing Subsequence
    Given an array of N positive integers. The task is to find the sum of the maximum sum decreasing subsequence(MSDS) of the given array such that the integers in the subsequence are sorted in decreasing order. Examples: Input: arr[] = {5, 4, 100, 3, 2, 101, 1} Output: 106 100 + 3 + 2 + 1 = 106 Input:
    7 min read
  • Printing Maximum Sum Increasing Subsequence
    The Maximum Sum Increasing Subsequence problem is to find the maximum sum subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order. Examples: Input: [1, 101, 2, 3, 100, 4, 5]Output: [1, 2, 3, 100]Input: [3, 4, 5, 10]Output: [3, 4, 5, 10]Input: [10, 5,
    15 min read
  • Maximum sum alternating subsequence
    Given an array, the task is to find sum of maximum sum alternating subsequence starting with first element. Here alternating sequence means first decreasing, then increasing, then decreasing, ... For example 10, 5, 14, 3 is an alternating sequence. Note that the reverse type of sequence (increasing
    13 min read
  • Maximum Sum Subsequence
    Given an array arr[] of size N, the task is to find the maximum sum non-empty subsequence present in the given array. Examples: Input: arr[] = { 2, 3, 7, 1, 9 } Output: 22 Explanation: Sum of the subsequence { arr[0], arr[1], arr[2], arr[3], arr[4] } is equal to 22, which is the maximum possible sum
    5 min read
  • Maximum Sum Subsequence of length k
    Given an array sequence [A1, A2 ...An], the task is to find the maximum possible sum of increasing subsequence S of length k such that S1<=S2<=S3.........<=Sk. Examples: Input : n = 8 k = 3 A=[8 5 9 10 5 6 21 8] Output : 40 Possible Increasing subsequence of Length 3 with maximum possible s
    11 min read
  • Longest subsequence having maximum sum
    Given an array arr[] of size N, the task is to find the longest non-empty subsequence from the given array whose sum is maximum. Examples: Input: arr[] = { 1, 2, -4, -2, 3, 0 } Output: 1 2 3 0 Explanation: Sum of elements of the subsequence {1, 2, 3, 0} is 6 which is the maximum possible sum. Theref
    8 min read
  • Maximum product of an increasing subsequence
    Given an array of numbers, find the maximum product formed by multiplying numbers of an increasing subsequence of that array. Note: A single number is supposed to be an increasing subsequence of size 1. Examples: Input : arr[] = { 3, 100, 4, 5, 150, 6 } Output : 45000 Maximum product is 45000 formed
    6 min read
  • Minimum number of increasing subsequences
    Given an array of integers of size N, you have to divide it into the minimum number of "strictly increasing subsequences" For example: let the sequence be {1, 3, 2, 4}, then the answer would be 2. In this case, the first increasing sequence would be {1, 3, 4} and the second would be {2}.Examples: In
    10 min read
  • POTD Solutions | 23 Oct’ 23 | Maximum Sum Increasing Subsequence
    View all POTD Solutions Welcome to the daily solutions of our PROBLEM OF THE DAY (POTD). We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Dynamic Programming but will also help you build up pro
    4 min read
  • Maximum sum subsequence of length K | Set 2
    Given an array sequence arr[] i.e [A1, A2 …An] and an integer k, the task is to find the maximum possible sum of increasing subsequence S of length k such that S1<=S2<=S3………<=Sk. Examples: Input: arr[] = {-1, 3, 4, 2, 5}, K = 3Output: 3 4 5Explanation: Subsequence 3 4 5 with sum 12 is the s
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences