Server Side Programming Articles

Page 1275 of 2109

Maximum sum of pairwise product in an array with negative allowed in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 250 Views

In this tutorial, we will be discussing a program to find maximum sum of pairwise product in an array with negative allowed.For this we will be provided with an array containing integers. Our task is to find the maximum sum while performing pairwise multiplications.Example#include #define Mod 1000000007 using namespace std; //finding the maximum sum long long int findSum(int arr[], int n) {    long long int sum = 0;    //sorting the array    sort(arr, arr + n);    int i = 0;    while (i < n && arr[i] < 0) {       if (i != ...

Read More

How to find the difference between row values starting from bottom of an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 268 Views

If an R data frame contains all numerical columns and we want to find the difference between row values then we will lose first row of the data frame because that will not be subtracted from any row. This can be done by using head function and minus sign. It will work as subtracting the second last row from the last row, then subtracting third last row from the second last row and so on.ExampleConsider the below data frame −x1

Read More

Maximum Sum of Products of Two Arrays in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 282 Views

In this tutorial, we will be discussing a program to find maximum Sum of Products of Two Arrays.For this we will be provided with two arrays of same size. Our task is to find the maximum sum by multiplying exactly one element from first element with one element from the second array.Example#include using namespace std; //calculating maximum sum by //multiplying elements int maximumSOP(int *a, int *b) {    int sop = 0;    int n = sizeof(a)/sizeof(a[0]);    sort(a,a+n+1);    sort(b,b+n+1);    for (int i = 0; i

Read More

How to convert the correlation matrix into a data frame with combination of variables and their correlations in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ Views

The cor function in R helps us to find the correlation matrix from a data frame or a matrix but the output of it always a matrix as intended. We might want to convert that matrix into a data frame which consists of all combination of variables with their correlation value. It can be done by reading the correlation matrix with as.table and converting that table into a data frame with as.data.frame.ExampleConsider the below data frame −x1

Read More

How to subset one or more sub-elements of a list in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 746 Views

A list contains different type of elements and each of the them can have varying elements. To subset these sub-elements we can use sapply function and use c to subset the number of corresponding sub-elements. For example, if we have a list that contains five elements and each of those elements have ten sub-elements then we can extract 1, 2, 3 etc elements from sub-elements.ExampleConsider the below list −x1

Read More

How to extract elements of a list that do not contain NULL in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

A list sometimes contains NULL elements along with other elements. Therefore, we might want to get rid of that NULL element so that we can use our list without any hustle. To do this, we can use lapply function with the following syntax −Syntax“List_name”[!unlist(lapply(“List_name”,is.null))]ExampleConsider the below list −x1

Read More

How to use shapiro wilk test to check normality of an R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 818 Views

To apply shapiro wilk test for normality on vectors, we just simply name the vector inside shapiro.test function but if we want to do the same for an R data frame column then the column will have to specify the column in a proper way. For example, if the data frame name is df and the column name is x then the function will work as shapiro.test(df$x).Examplex1

Read More

Maximum sum of smallest and second smallest in an array in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 218 Views

In this tutorial, we will be discussing a program to find maximum sum of smallest and second smallest in an array.For this we will be provided with an array containing integers. Our task is to find the maximum sum of smallest and second smallest elements in every possible iteration of array.Example#include using namespace std; //returning maximum sum of smallest and //second smallest elements int pairWithMaxSum(int arr[], int N) {    if (N < 2)       return -1;    int res = arr[0] + arr[1];    for (int i=1; i

Read More

Maximum sum path in a matrix from top to bottom in C++ Program

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 338 Views

In this tutorial, we will be discussing a program to find maximum sum path in a matrix from top to bottom.For this we will be provided with a matrix of N*N size. Our task is to find the maximum sum route from top row to bottom row while moving to diagonally higher cell.Example#include using namespace std; #define SIZE 10 //finding maximum sum path int maxSum(int mat[SIZE][SIZE], int n) {    if (n == 1)       return mat[0][0];    int dp[n][n];    int maxSum = INT_MIN, max;    for (int j = 0; j < n; j++)   ...

Read More

How to subset unique values from a list in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 556 Views

We know that a list in R can have multiple elements of different data types but they can be the same as well. Whether we have the same type of elements or different ones, we might want to subset the list with unique values, especially in situations where we believe that the values must be same. To do this, we can use unique function.ExampleConsider the below list −x1

Read More
Showing 12741–12750 of 21,090 articles
Advertisements