# Category Archives: Arrays

## Min difference between maximum and minimum element in all Y size subarrays

Given an array arr[] of size N and integer Y, the task is to find a minimum of all the differences between the maximum and… Read More »

## Queries for count of array elements with values in given range with updates

Given an array arr[] of size N and a matrix Q consisting of queries of the following two types: 1 L R : Print the… Read More »

## Longest subarray with difference exactly K between any two distinct values

Given an array arr[] of length N and an integer K, the task is to find the longest subarray with difference between any two distict… Read More »

## Reverse a subarray to maximize sum of even-indexed elements of given array

Given an array arr[], the task is to maximize the sum of even-indexed elements by reversing a subarray and print the maximum sum obtained. Examples:… Read More »

## Construct a sequence from given frequencies of N consecutive integers with unit adjacent difference

Given an array freq[] which stores the frequency of N integers from 0 to N – 1. The task is to construct a sequence where… Read More »

## Minimum distance between any most frequent and least frequent element of an array

Given an integer array arr[] of size N, the task is to find the minimum distance between any most and least frequent element of the… Read More »

## Check if frequency of each element in given array is unique or not

Given an array arr[] of N positive integers where the integers are in the range from 1 to N, the task is to check whether… Read More »

## How to store a very large number of more than 100 digits in C++

Given an integer N in form of string str consisting of more than 100 digits, the task is to store the value for performing an… Read More »

## Count of all pairs in an Array with minimum absolute difference

Given an integer array arr[] of size N, the task is to count the total number of distinct pairs having minimum absolute difference. Examples: Input:… Read More »

## Replace each element of Array with it’s corresponding rank

Given an array arr[] of N integers, the task is to replace each element of Array with their rank in array. The rank of an… Read More »

## Find pairs in array whose sum does not exist in Array

Given an array arr[] consisting of N positive integers, the task is to print all pairs of array elements whose sum does not exist in… Read More »

## Largest subset with M as smallest missing number

Given an array arr[] of N positive integers and a positive integer M, the task is to find the length of longest subset whose smallest… Read More »

## Count of all subsequences having adjacent elements with different parity

Given an array arr[] of size N, the task is to find the number of non-empty subsequences from the given array such that no two… Read More »

## Largest sum contiguous subarray having only non-negative elements

Given an integer array arr[], the task is to find the largest sum contiguous subarray of non-negative elements and return its sum. Examples: Input: arr[]… Read More »

## Check if a decreasing Array can be sorted using Triple cyclic shift

Given an arr[] of size N whose elements are sorted in descending order. The task is to find if the given array can be sorted… Read More »