# Category Archives: Competitive Programming

## Largest interval in an Array that contains the given element X for Q queries

Given an array arr[] of N elements and Q queries of the form [X]. For each query, the task is to find the largest interval… Read More »

## Minimum changes required to make all Array elements Prime

Given an array of integers arr[], the task is to count the minimum number of changes required to convert each array element to its nearest… Read More »

## Count all prime numbers in a given range whose sum of digits is also prime

Given two integers L and R, the task is to find the count of total numbers of prime numbers in the range [L, R] whose… Read More »

## Level order traversal in spiral form using stack and multimap

Given a binary tree of N nodes, the task is to print level order traversal in a spiral form. In spiral form, nodes at the… Read More »

## Count of ways to distribute N items among 3 people with one person receiving maximum

Given an integer N, the task is to find the total number of ways to distribute N among 3 people such that: Exactly one person… Read More »

## Change in Median of given array after deleting given elements

Given two arrays arr1[] and arr2[]. The array arr1[] is sorted. The task is to print the change in median after removing each element from… Read More »

## Count of pairs whose bitwise AND is a power of 2

Given an array arr[] of N positive integers. The task is to find the number of pairs whose Bitwise AND value is a power of… Read More »

## Generate Array whose sum of all K-size subarrays divided by N leaves remainder X

Given three integer N, K and X, the task is to create an array of length N suach that sum of all its K-length subarrays… Read More »

## Min number of moves to traverse entire Matrix through connected cells with equal values

Given a matrix A[][] of dimensions N*M, the task is to find the minimum number of moves required to traverse the entire matrix starting from… Read More »

## Count of triplets in an Array (i, j, k) such that i < j < k and a[k] < a[i] < a[j]

Given an array arr[] of N integers, the task is to count number of triplets (i, j, k) in the array such that a[k] <… Read More »

## Minimise N such that sum of count of all factors upto N is greater than or equal to X

Given a number X, the task is to find the minimum number N such that the sum of the count of all factors from 1… Read More »

## Check if the Matrix follows the given constraints or not

Given a matrix A[][] of size N*M, the task is to check if the given matrix satisfies the following two conditions or not: Sum of… Read More »

## Count of distinct numbers in an Array in a range for Online Queries using Merge Sort Tree

Given an array arr[] of size N and Q queries of the form [L, R], the task is to find the number of distinct values… Read More »

## Remove minimum characters from string to split it into three substrings under given constraints

Given a string str of lowercase alphabets, the task is to remove minimum characters from the given string so that string can be break into… Read More »

## How to implement text Auto-complete feature using Ternary Search Tree

Given a set of strings S and a string patt the task is to autocomplete the string patt to strings from S that have patt… Read More »