Check if an array is formed by consecutive integers

Check if an array is formed by consecutive integers

Problem Given an unsorted array of numbers, check if the array consists of consecutive numbers o…

Find triplet having maximum product in an array

Find triplet having maximum product in an array

Problem Find 3 numbers from the array such that their product is maximum. Sample Input […

Find the minimum index of a repeating element in an array

Find the minimum index of a repeating element in an array

Problem Given an array of integers, find the first repeating element in it. We need to find the …

Find a pair with a minimum absolute difference in an array

Find a pair with a minimum absolute difference in an array

Problem Given an unsorted array, find the minimum difference between any pair in a given array a…

Find two non-overlapping pairs having the same sum in an array

Find two non-overlapping pairs having the same sum in an array

Problem Given an unsorted array of integers. The task is to find any two non-overlapping pairs w…

Mountain Array

Mountain Array

Problem Given an array of integers, check if it is a mountain array or not. An array is called a…

Modular Exponentiation in Logarithmic Time

Modular Exponentiation in Logarithmic Time

Problem Given three integers, a, b, and p. Compute the value of (ab)%p. Sample Input a =…

Count subarrays with given XOR

Count subarrays with given XOR

Problem Given an array of integers, count the number of subarrays that have the XOR equal to &ls…

Find K-th Smallest Element in BST

Find K-th Smallest Element in BST

Problem Given a Binary Search Tree, find the k-th smallest element in the BST. Sample Input …

Find all symmetric pairs in an array of pairs

Find all symmetric pairs in an array of pairs

Problem Given an array of pairs, find all symmetric pairs in it. Symmetric pairs are two pairs (…

Find the closest pair from two arrays

Find the closest pair from two arrays

Problem Given two sorted arrays and an integer X, find one number from each array such that the …

Find the count of distinct elements in every subarray of size k

Find the count of distinct elements in every subarray of size k

Problem Given an array of integers and a number k. Find the count of distinct elements in every …