## Smallest subarray containing minimum and maximum values

Given an array A of size N. The task is to find the length of smallest subarray which contains both maximum and minimum values. Examples:… Read More »

## Check if a triplet with given sum exists in BST

Given a Binary Search Tree and a SUM. The task is to check if there exists any triplet(group of 3 elements) in the given BST… Read More »

## Count triplets in a sorted doubly linked list whose product is equal to a given value x

Given a sorted doubly linked list of distinct nodes(no two nodes have the same data) and a value x. The task is to count the… Read More »

## Count pairs in a sorted array whose product is less than k

Given a sorted integer array and number k, the task is to count pairs in an array whose product is less than x. Examples: Input:… Read More »

## Count number of triplets with product equal to given number | Set 2

Given an array of distinct integers(considering only positive numbers) and a number ‘m’, find the number of triplets with the product equal to ‘m’. Examples:… Read More »

## Minimum partitions of maximum size 2 and sum limited by given value

Given an array arr[] of positive numbers, find minimum number of sets in array which satisfy following property, 1. A set can contain maximum two… Read More »

## Print triplets with sum less than or equal to k

Given an array of distinct integers and a sum value. Print all triplets with sum smaller than given sum value. Expected Time Complexity is O(n2).… Read More »

## Sort an array where a subarray of a sorted array is in reverse order

Given an array of N numbers where a subarray is sorted in descending order and rest of the numbers in the array are in ascending… Read More »

## Closest product pair in an array

Given an array of non negative integers and a number x, find a pair in array whose product is closest to x. Examples : Input… Read More »

## Print uncommon elements from two sorted arrays

Given two sorted arrays of distinct elements, we need to print those elements from both arrays that are not common. The output should be printed… Read More »

## Count pairs from two sorted matrices with given sum

Given two sorted matrices mat1 and mat2 of size n x n of distinct elements. Given a value x. The problem is to count all… Read More »

## Two Pointers Technique

Two pointer is really an easy and effective technique which is typically used for searching pairs in a sorted arrays. Given a sorted array A… Read More »

## Find a triplet such that sum of two equals to third element

Given an array of integers you have to find three numbers such that sum of two elements equals the third element. Examples: Input : {5,… Read More »

## Find all triplets with zero sum

Given an array of distinct elements. The task is to find triplets in array whose sum is zero. Examples : Input : arr[] = {0,… Read More »

## Find the closest pair from two sorted arrays

Given two sorted arrays and a number x, find the pair whose sum is closest to x and the pair has an element from each… Read More »