# Category Archives: Arrays

## Count number of elements between two given elements in arrayOctober 16, 2017

Given an unsorted array of n elements and also given two points num1 and num2. The task is to count number of elements occurs between… Read More »

## k size subsets with maximum difference d between max and min

Given an array and two integers k and d, find the number of subsets of this array of size k, where difference between the maximum… Read More »

## Maximize value of (a[i]+i)*(a[j]+j) in an array

Given an array with input size n, find the maximum value of (a[i] + i) * (a[j] + j) where i is not equal to… Read More »

## Minimum product of k integers in an array of positive IntegersOctober 15, 2017

Given an array of n positive integers. We are required to write a program to print the minimum product of k integers of the given… Read More »

## Maximize the sum of arr[i]*i

Given an array of N integers. You are allowed to rearrange the element of the array. The task is to find the maximum value of… Read More »

## Pairs with Difference less than KOctober 14, 2017

Given an array of n integers, We need to find all pairs with difference less than k Examples: Input : a[] = {1, 10, 4,… Read More »

## Distance of closest zero to every element

Given an array of n integers, for each element, print the distance to the closest zero. Array has a minimum of 1 zero in it.… Read More »

## Mean of range in arrayOctober 13, 2017

Given an array of n integers. You are given q queries. Write a program to print floor value of mean in range l to r… Read More »

## Minimum cost to connect weighted nodes represented as array

Given an array of N elements(nodes), where every element is weight of that node.Connecting two nodes will take a cost of product of their weights.You… Read More »

## Print next greater number of Q queries

Given an array of n elements and q queries, for each query which has an index i, find the next greater element and print its… Read More »

## Number of subarrays whose minimum and maximum are same

Given an array of n integers, find the no of subarrays whose minimal and maximum elements are same. Subarray is defined as non-empty sequence of… Read More »

## Print modified array after executing the commands of addition and subtractionOctober 11, 2017

Given an array of size ‘n’ and a given set of commands of size ‘m’. Every command consist of four integers q, l, r, k.… Read More »

## Count ways of choosing a pair with maximum differenceOctober 8, 2017

Given an array of n integers, we need to find the no. of ways of choosing pairs with maximum difference. Examples: Input : a[] =… Read More »

## Longest alternating sub-array starting from every index in a Binary Array

Given an array containing only 0s and 1s. For each index ‘i‘(0 index), find length of the longest alternating sub-array starting from ‘i‘ to ‘j‘… Read More »

## Rearrange array such that even index elements are smaller and odd index elements are greater

Given an array, rearrange the array such that : If index i is even, arr[i] <= arr[i+1] If index i is odd, arr[i] >= arr[i+1]… Read More »