#include using namespace std;int maximizeAnd(int i, int mask, int* A, int* B, int N, vector& dp){ if (i == N) return 0; if (dp[i][mask] !=…

# array-rearrange

### Minimize sum of product of same-indexed elements of two arrays by reversing a subarray of one of the two arrays

import java.io.*;import java.util.*; public class Main { static void minimumProdArray(long a[], long b[], int l) { long total = 0; for (int i = 0; i…

### Check if removal of a subsequence of non-adjacent elements makes the array sorted

Check if removal of a subsequence of non-adjacent elements makes the array sortedGiven a binary array arr[] of size N,…

### Minimum number of operations required to make a permutation of first N natural numbers equal

Minimum number of operations required to make a permutation of first N natural numbers equalGiven an array A[] of size…

### Maximize product of a matrix by repeatedly multiplying pairs of adjacent cells with -1

#include using namespace std; int maxProduct(vector arr){ int N = arr.size(); int cnt = 0; int zeros = 0; int maxValue = INT_MIN; vector v; for (int…

### Minimize sum of absolute differences of same-indexed elements of two given arrays by at most one replacement

#include using namespace std; int minAbsoluteSumDiff(vector A, vector B, int N){ int sum = 0; int diff[N]; for (int i = 0; i < N;…

### Minimum removal of elements from end of an array required to obtain sum K

#include using namespace std; int minSizeArr(int A[], int N, int K){ int leftTaken = N, rightTaken = N; int leftSum = 0, rightSum…

### Minimum operations required to make all elements in an array of first N odd numbers equal

Minimum operations required to make all elements in an array of first N odd numbers equalGiven an array consisting of…

### Maximum subarray sum possible after removing at most one subarray

import java.io.*;import java.util.*; class GFG { public static void maximumSum( int arr[], int n) { long[] preSum = new long[n]; long sum = 0; long maxSum =…

### Check whether an array can be made strictly increasing by removing at most one element

Check whether an array can be made strictly increasing by removing at most one elementGiven an array arr[] consisting of…