# Category Archives: Competitive Programming

## Number of Isosceles triangles in a binary tree

Pre-Requisites: Depth First Search | Parent Array Representation Given a parent array representation of a binary tree, we need to find the number of Isosceles… Read More »

## Find Four points such that they form a square whose sides are parallel to x and y axes

Given ‘n’ pair of points, the task is to find four points such that they form a square whose sides are parallel to x and… Read More »

## Pair of prime numbers with a given sum and minimum absolute difference

Given an integer ‘sum’ (less than 10^8), the task is to find a pair of prime numbers whose sum is equal to the given ‘sum’… Read More »

## Longest subarray with only one value greater than k

Given an array of N numbers, find length of the longest subarray such that K is the second largest element on insertion. Examples: Input: a[]… Read More »

## Print values of ‘a’ in equation (a+b) <= n and a+b is divisible by x

Given three numbers b, x, n. The task is to find the values of ‘a’ in equation (a+b) <= n such that a+b is divisible… Read More »

## Kth prime number greater than N

Given a number N, the task is to print the Kth prime number greater than N. Note: N and K are so given such that… Read More »

## Difference between the largest and the smallest primes in an array

Given an array of integers where all the elements are less than 10^6. The task is to find the difference between the largest and the… Read More »

## Number of distinct integers obtained by lcm(X, N)/X

Given a number , find the number of distinct integers obtained by lcm(X, N)/X where X can be any positive number. Examples: Input: N =… Read More »

## Numbers in range [L, R] such that the count of their divisors is both even and prime

Given a range [L, R], the task is to find the numbers from the range which have the count of their divisors as even as… Read More »

## Number of mismatching bits in the binary representation of two integers

Given two integers(less than 2^31) A and B. The task is to find the number of bits that are different in their binary representation. Examples:… Read More »

## Sum of every K’th prime number in an array

Given an array of integers (less than 10^6), the task is to find the sum of all the prime numbers which appear after every (k-1)… Read More »

## Check if a king can move a valid move or not when N nights are there in a modified chessboard

Given an infinite chessboard with the same rules as that of chess. Also given are N knights coordinates on the infinite chessboard(-10^9 <= x, y… Read More »

## Minimum increment operations to make the array in increasing order

Given an array of size N and X. Find minimum moves required to make the array in increasing order. In each move one can add… Read More »

## Print N lines of 4 numbers such that every pair among 4 numbers has a GCD K

Given N and K, the task is to print N lines where each line contains 4 numbers such that every among those 4 numbers has… Read More »

## Check if a large number is divisible by 2, 3 and 5 or not

Given a number, the task is to check if a number is divisible by 2, 3 and 5 or not. The input number may be… Read More »