# Tag Archives: two-pointer-algorithm

## Minimize difference between maximum and minimum array elements by exactly K removals

Given an array arr[] consisting of N positive integers and an integer K, the task is to minimize the difference between the maximum and minimum… Read More »

## Maximize the minimum array element by M subarray increments of size S

Given an array arr[] of N integers and two integers S and M, the task is to maximize the minimum array element by incrementing any… Read More »

## Rearrange array to maximize count of local minima

Given an array arr[] of size N, the task is to rearrange the array elements such that the count of local minima in the array… Read More »

## Count pairs from two arrays with difference exceeding K | set 2

Given two integer arrays arr[] and brr[] consisting of distinct elements of size N and M respectively and an integer K, the task is to… Read More »

## Count pairs from two arrays with difference exceeding K

Given two integer arrays arr[] and brr[] consisting of distinct elements of size N and M respectively and an integer K, the task is to… Read More »

## Length of longest subarray with increasing contiguous elements

Given an array arr[] of length N, the task is to find the length of the longest subarray which consists of consecutive numbers in increasing… Read More »

## Rearrange array by interchanging positions of even and odd elements in the given array

Given an array arr[] of N positive integers with an equal number of even and odd elements. The task is to use in-place swapping to… Read More »

## Count minimum number of fountains to be activated to cover the entire garden

There is a one-dimensional garden of length N. In each position of the N length garden, a fountain has been installed. Given an array a[]such… Read More »

## Count ways to distribute exactly one coin to each worker

Given two arrays coins[] and salaries[] where coins[i] represents the value of ith coin and salaries[j] represents the minimum value of the coin that jth… Read More »

## Largest Sum Contiguous Subarray having unique elements

Given an array arr[] of N positive integers, the task is to find the subarray having maximum sum among all subarrays having unique elements and… Read More »

## Split array into minimum number of subarrays having GCD of its first and last element exceeding 1

Given an array arr[] of size N, the task is to split the entire array into a minimum number of subarrays such that for each… Read More »

## Length of longest subarray having only K distinct Prime Numbers

Given an array arr[] consisting of N positive integers. The task is to find the length of the longest subarray of this array that contains… Read More »

## Find the elements appearing even number of times in an Array

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and… Read More »

## Longest Subarrays having each Array element as the maximum

Given an array arr[] of length N, the task is to find the longest subarray for each array element arr[i], which contains arr[i] as the… 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 »