# Category Archives: Arrays

## Check if a subarray of size K exists whose elements form a number divisible by 3

Given an array arr[], of size N and a positive integer K, the task is to find a subarray of size K whose elements can… Read More »

## Check if array can be sorted by swapping pairs having GCD equal to the smallest element in the array

Given an array arr[] of size N, the task is to check if an array can be sorted by swapping only the elements whose GCD… Read More »

## Priority Queue using Binary Heap

Priority Queue is an extension of the queue with the following properties:   Every item has a priority associated with it. An element with high priority… Read More »

## Number from a range [L, R] having Kth minimum cost of conversion to 1 by given operations

Given three integers L, R and K where [L, R] denotes the range of elements, the task is to find the element in the range… Read More »

## Count permutations of given array that generates the same Binary Search Tree (BST)

Given an array, arr[] of size N consisting of elements from the range [1, N], that represents the order, in which the elements are inserted… Read More »

## Check if all array elements are present in a given stack or not

Given a stack of integers S and an array of integers arr[], the task is to check if all the array elements are present in… Read More »

## Check if any permutation of array contains sum of every adjacent pair not divisible by 3

Given an array arr[] consisting of N integers, the task is to check if any permutation of the array elements exists where the sum of… Read More »

## Sum of all ordered pair-products from a given array

Given an array arr[] of size N, the task is to find the sum of all products of ordered pairs that can be generated from… Read More »

## Queries to find maximum sum contiguous subarrays of given length in a rotating array

Given an array arr[] of N integers and Q queries of the form {X, Y} of the following two types: If X = 1, rotate… Read More »

## Longest subsequence forming an Arithmetic Progression (AP)

Given an array arr[] consisting of N integers, the task is to find the length of the longest subsequence than forms an Arithmetic Progression. Examples:… Read More »

## Maximize sum of remaining elements after every removal of the array half with greater sum

Given an array arr[] consisting of N integers, the task is to maximize the resultant sum obtained after adding remaining elements after every removal of… Read More »

## Maximum time in HH:MM:SS format that can be represented by given six digits

Given an array arr[] consisting of six integer digits only, the task is to return the maximum time in a 24-hour format that can be… Read More »

## Find K smallest leaf nodes from a given Binary Tree

Given a binary tree and an integer K, the task is to find the K smallest leaf nodes from the given binary tree. The number… Read More »

## Length of longest increasing prime subsequence from a given array

Given an array arr[] consisting of N positive integers, the task is to find the length of the longest increasing subsequence consisting of Prime Numbers… Read More »

## Nth term of a recurrence relation generated by two given arrays

Given an integer N and two arrays F[] and C[] of size K that represent the first K terms and coefficient of first K terms… Read More »