Server Side Programming Articles

Page 1182 of 2109

Eulerian Number in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 644 Views

In mathematics, the Eulerian number is a special type of combination number. It defines the number of permutations in which the next element is a specific number greater than the previous one.Denoted as,  A(n, m) is permutation from 1 to n in which two numbers vary by m.Problem Statement: In this problem, we are given two numbers m and n. And we need to find the number of permutations that are the Eulerian Number.Let’s take an example to understand the problem, Input:  n = 4, m = 2Output: 11Explanation: All permutations of number from 1 to 4 are −1 2 3 4       ...

Read More

Maximum sum alternating subsequence in C++ program

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 529 Views

In this problem, we are given an array arr[] of n integers. Our task is to create a program to find the Maximum sum alternating subsequence starting from the first element of the array.An alternating subsequence is a subsequence in which elements are increasing and decreasing in an alternating order i.e. first decreasing, then increasing, then decreasing. Here, the reverse alternating subsequence is not valid for finding the maximum sum.Let’s take an example to understand the problem, Inputarr[] = {5, 1, 6, 2, 4, 8, 9}Output27ExplanationStarting element: 5, decrease: 1, increase: 6, decrease: 2, increase:4, N.A. Here, we can use ...

Read More

Evaluate a boolean expression represented as string in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 792 Views

In this problem, we are given a string exp that represents a boolean expression. Our task is to evaluate the boolean expression represented as String.The valid characters in the expression are −0 or 1 denoting the boolean value& denoting AND operation| denoting OR operation^ denoting XOR operationWe need to solve this expression and return the result.Let's take an example to understand the problem, Input: str = 1&1|0^1^0&1Output: 0Explanation: 1&1|0^1^0&11 AND 1 OR 0 XOR 1 XOR 0 AND 11 OR 0 XOR 1 XOR 0 AND 11 XOR 1 XOR 0 AND 10 XOR 0 AND 10 AND 10Solution Approach:A simple solution is ...

Read More

Maximum sum by picking elements from two arrays in order in C++ Program

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 939 Views

In this problem, we are given two arrays arr1[] and arr2[], and two numbers N and M.N gives the number of elements taken from arr1.M gives the number of elements taken from arr2.We need to select one of the elements from arr1[i] to arr2[i], for whichmakes the sum maximum, but maximum N can be taken from arr1 and M from arr2.Our task is to create a program to find the maximum sum by picking elements from two arrays in order in C++.Let’s take an example to understand the problem, Inputarr1[] = {5, 1, 6, 2, 8, 9} arr2[] = {8, ...

Read More

Evaluate an array expression with numbers, + and - in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 353 Views

In this problem, we are given an array arr[] consisting of n character values denoting an expression. Our task is to evaluate an array expression with numbers, + and –. The expression consists of only, numbers, ‘+’ character and ‘- ’ character.Let’s take an example to understand the problem, Input: arr = {“5”, “+”, “2”, “-8”, “+”, “9”, }Output: 8Explanation: The expression is 5 + 2 - 8 + 9 = 8Solution Approach:The solution to the problem is found by performing each operation and then returning the value. Each number needs to be converted to its equivalent integer value.Program to illustrate the working of ...

Read More

Maximum Sum Increasing Subsequence using Binary Indexed Tree in C++ program

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 226 Views

In this problem, we are given an array arr[] of n integers. Our task is to create a program to find the maximum sum increasing subsequence using binary indexed tree in C++.Problem Description − We need to find an increasing subsequence with the maximum sum using the elements of the array.Increasing Subsequence − subsequence in which the value of the current element is greater than the element at the previous position.Binary Indexed Tree − It is a data structure which is a type of tree. We can add or remove elements from the tree in an effective way.Let’s take an ...

Read More

Evaluation of Risk in Investments in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 237 Views

In this problem, we are given two arrays each denoting an investment plan. Our task is to perform the evaluation of Risk in Investment and find which of the two investments is more promising.Both the investments I1[][] and I2[][] has a set of outcomes and the probability of that investment outcome.Using these values, we need to find the risk in each investment and then print the better investment out of the two investments.For this, we will be using statistical mathematics and find some values that will help us conclude to the better investment.We will find these values, Mean or average amount ...

Read More

Maximum sum of increasing order elements from n arrays in C++ program

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 251 Views

In this problem, we are given a 2-D matrix of size nXm. Our task is to create a program to find the maximum sum of increasing order elements from n arrays.Program Description − Here, we need to find the maximum sum of elements by taking one element from each row in such a way that the element from ith row is less than the element from (i+1)th row. And so on. If no such sum is possible, return −1 denoting no result possible.Let’s take an example to understand the problem, Inputmat[][] = {    {4, 5, 1, 3, 6},   ...

Read More

Evaluation order of operands in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 284 Views

There are some rules in programming that govern how an operation is performed.The order of evaluation of operation and the associativity of operations (which is left to right is defined).Here is a program to show the evaluation order of operands,Example#include using namespace std; int x = 2; int changeVal() {    x *= x;    return x; } int main() {        int p = changeVal() + changeVal();    cout

Read More

Maximum sum of nodes in Binary tree such that no two are adjacent using Dynamic Programming in C++ program

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 531 Views

In this problem, we are given a Binary Tree with each node having a value. Our task is to create a program to find the Maximum sum of nodes in Binary tree such that no two are adjacent using Dynamic Programming.Problem Description − We will be choosing the subsets of the binary tree to make the sum maximum in such a way that the nodes are not connected directly.Let’s take an example to understand the problem, InputOutput24ExplanationElements to be taken under consideration are: 8 + 5 + 9 + 2 = 24Solution ApproachA solution to the problem is by using ...

Read More
Showing 11811–11820 of 21,090 articles
Advertisements