- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7347 Articles for C++
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
117 Views
In this tutorial, we will be discussing a program to find maximum sum of increasing order elements from n arrays.For this we will be provided with N arrays of M size. Our task is to find the maximum sum by selecting one element from each array such that element from the previous array is smaller than the next one.Example Live Demo#include #define M 4 using namespace std; //calculating maximum sum by selecting //one element int maximumSum(int a[][M], int n) { for (int i = 0; i < n; i++) sort(a[i], a[i] + M); int sum ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
92 Views
In this tutorial, we will be discussing a program to find maximum product of indexes of next greater on left and right.For this we will be provided with an array of integers. Our task is to find the element with maximum Left-Right product (L(i)*R(i) where L(i) is closest index on left side and greater than current element and R(i) is closest index on right side and greater than current element).Example Live Demo#include using namespace std; #define MAX 1000 //finding greater element on left side vector nextGreaterInLeft(int a[], int n) { vector left_index(MAX, 0); stack s; for (int ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
75 Views
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 Live Demo#include #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++) ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
81 Views
In this tutorial, we will be discussing a program to find maximum product of an increasing subsequence of size 3.For this we will be provided with an array of positive integers. Our task is to find a subsequence of three elements with the maximum product.Example#include using namespace std; //returning maximum product of subsequence long long int maxProduct(int arr[] , int n) { int smaller[n]; smaller[0] = -1 ; setS ; for (int i = 0; i < n ; i++) { auto j = S.insert(arr[i]); auto itc = j.first; ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
73 Views
In this tutorial, we will be discussing a program to find maximum product of a triplet (subsequence of size 3) in array.For this we will be provided with an array of integers. Our task is to find the triplet of elements in that array with the maximum productExample Live Demo#include using namespace std; //finding the maximum product int maxProduct(int arr[], int n){ if (n < 3) return -1; int max_product = INT_MIN; for (int i = 0; i < n - 2; i++) for (int j = i + 1; j ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
202 Views
In this tutorial, we will be discussing a program to find maximum product of 4 adjacent elements in matrix.For this we will be provided with a square matrix. Our task is to find the maximum product of four adjacent elements which can be top, down, right, left, or diagonal.Example Live Demo#include using namespace std; const int n = 5; //finding maximum product int FindMaxProduct(int arr[][n], int n) { int max = 0, result; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
87 Views
In this tutorial, we will be discussing a program to find maximum product from array such that frequency sum of all repeating elements in product is less than or equal to 2 * k.For this we will be provided with an array and an integer k. Our task is to find the maximum product from the array given that the frequency sum of all digits must be smaller than or equal to 2 * k.Example Live Demo#include using namespace std; #define ll long long int //returning maximum product value ll maxProd(int arr[], int n, int k) { ll product ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
99 Views
In this tutorial, we will be discussing a program to find maximum Product Cutting | DP-36.For this we will be provided with a rope of N meters. Our task is to cut the rope in different integer lengths such that the product of their lengths is the maximumExample Live Demo#include using namespace std; //finding maximum of two, three integers int max(int a, int b) { return (a > b)? a : b; } int max(int a, int b, int c) { return max(a, max(b, c)); } //returning maximum product int maxProd(int n) { if (n == 0 ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
216 Views
In this tutorial, we will be discussing a program to find maximum power of jump required to reach the end of string.For this we will be provided with a string of 0s and 1s. Our task is to find the maximum jump required to move from front to end of string given you can move to the same element as current one.Example Live Demo#include using namespace std; //finding maximum power jump int powerOfJump(string s) { int count = 1; int max_so_far = INT_MIN; char ch = s[s.length() - 1]; for (int i = 0; i < s.length(); ... Read More
![Ayush Gupta](https://www.tutorialspoint.com/assets/profiles/134135/profile/60_13095-1568350695.jpg)
272 Views
In this tutorial, we will be discussing a program to find maximum possible time that can be formed from four digits.For this we will be provided with an array consisting 4 digits. Our task is to find the maximum time (24 hour format) that can formed using those four digits.Example Live Demo#include using namespace std; //returning updated frequency map map getFrequencyMap(int arr[], int n) { map hashMap; for (int i = 0; i < n; i++) { hashMap[arr[i]]++; } return hashMap; } //checking if the digit is present in frequency map bool hasDigit(map* ... Read More