# Category Archives: Arrays

## Maximum distance between two elements whose absolute difference is K

Given an array arr[] and a number K, the task to find the maximum distance between two elements whose absolute difference is K. If it… Read More »

## Count of ways to split an Array into three contiguous Subarrays having increasing Sum

Given an array arr[] consisting of non-negative integers, the task is to find the number of ways to split the array into three non-empty contiguous… Read More »

## Rearrange array such that all even-indexed elements in the Array is even

Given an array arr[], the task is to check if it is possible to rearrange the array in such a way that every even index(1-based… Read More »

## Find prime factors of Array elements whose sum of exponents is divisible by K

Given an array arr[] of N positive integers and an integer K., The task is to create a set of prime numbers such that the… Read More »

## Minimize Cost to reduce the Array to a single element by given operations

Given an array a[] consisting of N integers and an integer K, the task is to find the minimum cost to reduce the given array… Read More »

## Minimum Decrements on Subarrays required to reduce all Array elements to zero

Given an array arr[] consisting of N non-negative integers, the task is to find the minimum number of subarrays that needs to be reduced by… Read More »

## Detect Cycle in a 2D grid

Given a 2D grid arr[][] with different characters, the task is to detect whether it contains a cycle or not. A sequence of characters or… Read More »

## Check if Array forms an increasing-decreasing sequence or vice versa

Given an array arr[] of N integers, the task is to find if the array can be divided into 2 sub-array such that the first… Read More »

## Count of index pairs with equal elements in an array | Set 2

Given an array arr[] of N elements. The task is to count the total number of indices (i, j) such that arr[i] = arr[j] and… Read More »

## Check if an Array can be Sorted by picking only the corner Array elements

Given an array arr[] consisting of N elements, the task is to check if the given array can be sorted by picking only corner elements… Read More »

## Sort an Array of Version Numbers

Given an array of strings arr[], consisting of N strings each representing dot separated numbers in the form of software versions. Input: arr[] = {“1.1.2”,… Read More »

## Minimum Sum of Euclidean Distances to all given Points

Given a matrix mat[][] consisting of N pairs of the form {x, y} each denoting coordinates of N points, the task is to find the… Read More »

## Median of difference of all pairs from an Array

Given an array arr[] of length N, the task is to find the median of the differences of all pairs of the array elements. Example:… Read More »

## Maximize the last Array element as per the given conditions

Given an array arr[] consisting of N integers, rearrange the array such that it satisfies the following conditions: arr must be 1. Difference between adjacent… Read More »

## Find the point on X-axis from given N points having least Sum of Distances from all other points

Given an array arr[] consisting of N integers, denoting N points lying on the X-axis, the task is to find the point which has the… Read More »