# Category Archives: Arrays

## Longest increasing subarray

Given an array containing n numbers. The problem is to find the length of the longest contiguous subarray such that every element in the subarray… Read More »

## Find minimum cost to buy all books

Given an array of ratings for n books. Find the minimum cost to buy all books with below conditions : Cost of every book would… Read More »

## Find an element in array such that sum of left array is equal to sum of right array

Given, an array of size n. Find an element which divides the array in two sub-arrays with equal sum. Examples: Input : 1 4 2… Read More »

## Minimum absolute difference of XOR values of two subarrays

Given an array containing n numbers. The problem is to split the array into two subarrays such that the absolute difference of the xor values… Read More »

## Move all negative numbers to beginning and positive to end with constant extra space

An array contains both positive and negative numbers in random order. Rearrange the array elements so that all negative numbers appear before all Examples: Input… Read More »

## Collect maximum points in an array with k moves

Given an array of integer and two value k and i where k is number of moves and i is index in array. Task is… Read More »

## Count number of distinct pairs whose sum exists in the given array

Given an array of N positive integers. Count the number of pairs whose sum exists in the given array. While repeating pairs will not be… Read More »

## Binary array after M range toggle operations

Consider a binary array consisting of N elements (initially all elements are 0). After that you are given M commands where each command is of… Read More »

## Sum of array elements that is first continuously increasing then decreasing

Given an array where elements are first continuously increasing and after that its continuously decreasing unit first number is reached again. We want to add… Read More »

## Longest Subarray having sum of elements atmost ‘k’

Given an array of integers, our goal is to find the length of largest subarray having sum of its elements atmost ‘k’ where k>0. Examples:… Read More »

## Smallest element repeated exactly ‘k’ times (not limited to small range)

Given an array of size n, the goal is to find out the smallest number that is repeated exactly ‘k’ times where k > 0?… Read More »

## Find element in a sorted array whose frequency is greater than or equal to n/2.

Given a sorted array of length n, find the number in array that appears more than or equal to n/2 times. It is given that… Read More »

## Sort first half in ascending and second half in descending order

Given an array of integers, sort the first half of the array in ascending order and second half in descending order. Examples: Input : arr[]… Read More »

## Maximum Weight Difference

You are given an array W[1], W[2], …, W[N]. Choose K numbers among them such that the absolute difference between the sum of chosen numbers… Read More »

## Sum of all subarrays of array | Set 2

Given an array of n integers. Find the sum of all possible subarrays. Examples: Input : arr[] = { 1, 2 } Output : 6… Read More »