
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Maximum product of an increasing subsequence in C++
In this tutorial, we will be discussing a program to find maximum product of an increasing subsequence.
For this we will be provided with an array of integers. Our task is to find the maximum product of any subsequence of the array with any number of elements.
Example
#include <bits/stdc++.h> #define ll long long int using namespace std; //returning maximum product ll lis(ll arr[], ll n) { ll mpis[n]; //initiating values for (int i = 0; i < n; i++) mpis[i] = arr[i]; for (int i = 1; i < n; i++) for (int j = 0; j < i; j++) if (arr[i] > arr[j] && mpis[i] < (mpis[j] * arr[i])) mpis[i] = mpis[j] * arr[i]; return *max_element(mpis, mpis + n); } int main() { ll arr[] = { 3, 100, 4, 5, 150, 6 }; ll n = sizeof(arr) / sizeof(arr[0]); printf("%lld", lis(arr, n)); return 0; }
Output
45000
- Related Articles
- Maximum product of an increasing subsequence in C++ Program
- Maximum product of an increasing subsequence of size 3 in C++
- Maximum product of an increasing subsequence of size 3 in C++ program
- Maximum Sum Increasing Subsequence\n
- Maximum Sum Increasing Subsequence | DP-14 in C++
- Maximum product of subsequence of size k in C++
- Maximum Sum Increasing Subsequence using DP in C++ program
- Maximum Sum Increasing Subsequence using Binary Indexed Tree in C++
- Maximum Sum Increasing Subsequence using Binary Indexed Tree in C++ program
- Longest Increasing Subsequence
- Maximum product of a triplet (subsequence of size 3) in array in C++
- Longest Increasing Subsequence in Python
- Increasing Triplet Subsequence in Python
- Number of Longest Increasing Subsequence in C++
- Maximum product of a triplet (subsequence of size 3) in array in C++ Program.

Advertisements