# Category Archives: Arrays

## Construct a distinct elements array with given size, sum and element upper boundNovember 20, 2017

Given N size of the original array, SUM total sum of all elements present in the array and K such that no element in array… Read More »

## Number of subarrays with maximum values in given range

Given an array of N elements and L and R, print the number of sub-arrays such that the value of the maximum array element in… Read More »

## Find minimum in an array without using Relational Operators

Given an array A[] of non-negative integers, find the minimum in the array without using Relational Operators. Examples: Input : A[] = {2, 3, 1,… Read More »

## Minimum flips to make all 1s in left and 0s in right | Set 2November 19, 2017

Given a binary array, we can flip all the 1 are in the left part and all the 0 to the right part.Calculate the minimum… Read More »

## Minimum flips to make all 1s in left and 0s in right | Set 1 (Using Bitmask)

Given a binary array, we can flip all the 1 are in the left part and all the 0 to the right part.Calculate the minimum… Read More »

## Minimum gcd operations to make all array elements one

Given an array A[] of size N. You can replace any number in the array with the gcd of that element with any of its… Read More »

## Last seen array element (last appearance is earliest)

Given an array that might contain duplicates, find the element whose last appearance is latest. Examples: Input : arr[] = {10, 30, 20, 10, 20}… Read More »

## Pair with given sum and maximum shortest distance from endNovember 17, 2017

Given an array of N integers and an integer K, pick two distinct elements whose sum is K and find the maximum shortest distance of… Read More »

## GCD of array is greater than one

Given an array of n integers. The array is considered best if GCD of all its elements is greater than 1. If the array is… Read More »

## Count sub-arrays which have elements less than or equal to X

Given an array of n elements and an integer X. Count the number of sub-arrays of this array which have all elements less than or… Read More »

## Differences between number of increasing subarrays and decreasing subarrays in k sized windowsNovember 16, 2017

Given an array of integers and k, find the difference between the number of the strictly increasing number of subarrays (of size more than one)… Read More »

## Longest subsequence having equal numbers of 0 and 1

Given a binary array, the task is find the size of the largest sub_sequence which having equal number of zeros and one. Input : arr[]… Read More »

## Number of visible boxes after putting one inside another

Given N boxes and their size in an array. You are allowed to keep a box inside another box only if the box in which… Read More »

## Longest sequence of positive integers in an array

Find the longest running positive sequence in an array. Examples: Input : arr[] = {1, 2, -3, 2, 3, 4, -6, 1, 2, 3, 4,… Read More »

## Maximum consecutive numbers present in an array

Find the length of maximum number of consecutive numbers jumbled up in an array. Examples: Input : arr[] = {1, 94, 93, 1000, 5, 92,… Read More »