
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 7197 Articles for C++

138 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

276 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

130 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

172 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

258 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

331 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

109 Views
In this tutorial, we will be discussing a program to find maximum possible sum of a window in an array such that elements of same window in other array are unique.For this we will be provided with two arrays with equal number of elements. Our task is to find the window in one element with maximum sum such that the same window in other array is unique.Example Live Demo#include using namespace std; //returning maximum sum window int returnMaxSum(int A[], int B[], int n) { //storing elements with their count unordered_set mp; int result = 0; int ... Read More

270 Views
In this tutorial, we will be discussing a program to find maximum Possible Product in Array after performing given OperationsFor this we will be provided with an array of size N. Our task is to perform N-1 operations (changing a[j] → a[i]*a[j] and remove a[i] value or just remove the value of a[i] (only once)) such that the remaining values are the maximum ones only.Example Live Demo#include using namespace std; //printing operations void MaximumProduct(int a[], int n) { int cntneg = 0; int cntzero = 0; int used[n] = { 0 }; int pos = -1; ... Read More

211 Views
In this tutorial, we will be discussing a program to find maximum possible middle element of the array after deleting exactly k elementsFor this we will be provided with an array of size N and an integer K. Our task is to reduce K elements from the array such that the middle element of the resulting array is maximum.Example Live Demo#include using namespace std; //calculating maximum value of middle element int maximum_middle_value(int n, int k, int arr[]) { int ans = -1; int low = (n + 1 - k) / 2; int high = (n + ... Read More

123 Views
In this tutorial, we will be discussing a program to find maximum possible intersection by moving centers of line segmentsFor this we will be provided with the center of three line segments and their length. Our task is to move their center by K distance to increase the length of intersection region.Example Live Demo#include using namespace std; //finding maximum intersection int max_intersection(int* center, int length, int k) { sort(center, center + 3); if (center[2] - center[0] >= 2 * k + length) { return 0; } else if (center[2] - center[0] >= 2 ... Read More