# Category Archives: Arrays

## Queries to increment array elements in a given range by a given value for a given number of times

Given an array arr[] of N positive integers and M queries of the form {a, b, val, f}. The task is to print the array… Read More »

## Count unique paths is a matrix whose product of elements contains odd number of divisors

Given a matrix mat[][] of dimension NxM, the task is to count the number of unique paths from the top-left cell, i.e. mat, to the… Read More »

## Program to find weighted median of a given array

Given two arrays arr[] of N integers and W[] of N weights where W[i] is the weight for the element arr[i]. The task is to… Read More »

## Count subarrays of atleast size 3 forming a Geometric Progression (GP)

Given an array arr[] of N integers, the task is to find the count of all subarrays from the given array of at least size… Read More »

## Maximize sum possible by selecting K array elements followed by decrementing them by 1

Given an array arr[] consisting of N positive integers and an integer K. In one operation, select an array element, add it to the sum… Read More »

## Count right angled triangles in a matrix having two of its sides parallel to sides of the matrix

Given a binary matrix arr[][] of dimensions N * M , the task is to count the number of right-angled triangles that can be formed… Read More »

## Count pairs whose sum consists of set bits only

Given an array arr[] consisting of N integers, the task is to find the count of unordered pairs in the given array whose sum contains… Read More »

## Count minimum number of fountains to be activated to cover the entire garden

There is a one-dimensional garden of length N. In each position of the N length garden, a fountain has been installed. Given an array a[]such… Read More »

## Bitwise XOR of all unordered pairs from a given array

Given an array arr[] of size N, the task is to find the bitwise XOR of all possible unordered pairs of the given array.  Examples:… Read More »

## Count triplets having product 0 from a given array

Given an array arr[] of size N, the task is to count the number of triplets (arr[i], arr[j], arr[k]) such that arr[i] * arr[j] =… Read More »

## Longest palindromic string possible by concatenating strings from a given array

Given an array of strings S[] consisting of N distinct strings of length M. The task is to generate the longest possible palindromic string by… Read More »

## Maximum number of Perfect Numbers present in a subarray of size K

Given an array arr[ ] consisting of N integers, the task is to determine the maximum number of perfect Numbers in any subarray of size… Read More »

## Maximum possible sum of non-adjacent array elements not exceeding K

Given an array arr[] consisting of N integers and an integer K, the task is to select some non-adjacent array elements with maximum possible sum… Read More »

## Check if a given array can be divided into pairs with even sum

Given an array arr[] consisting of N integers, the task is to check if it is possible to divide the entire array into pairs such… Read More »

## Rearrange array to make product of prefix sum array non zero

Given an array, arr[ ] of size N, the task is to rearrange the given array such that the product of all the elements of… Read More »