## Sum of (maximum element – minimum element) for all the subsets of an array.

Given an array arr[], the task is to compute the sum of (max{A} – min{A}) for every non-empty subset A of the array arr[]. Examples:… Read More »

## Number of ways to remove elements to maximize arithmetic mean

Given an array arr[], the task is to find the number of ways to remove elements from the array so as to maximize the arithmetic… Read More »

## Count of all N digit numbers such that num + Rev(num) = 10^N – 1

Given an integer N, the task is to find the count of all N digit numbers such that num + Rev(num) = 10N – 1… Read More »

## Smallest integer > 1 which divides every element of the given array

Given an array arr[], the task is to find the smallest possible integer (other than 1) which divides every element of the given array. Examples:… Read More »

## Numbers that are not divisible by any number in the range [2, 10]

Given an integer N. The task is to find the count of all the numbers from 1 to N which are not divisible by any… Read More »

## Largest subset of rectangles such that no rectangle fit in any other rectangle

Given height and width of N rectangles. The task is to find the size of the largest subset such that no pair of rectangles fit… Read More »

## Count permutations that are first decreasing then increasing.

Given an integer N, calculate the number of permutations of A = [1, 2, …, N] which are first decreasing and then increasing. Examples: Input:… Read More »

## Find the count of numbers that can be formed using digits 3, 4 only and having length at max N.

Given a number N. Find the count of such numbers that can be formed using digits 3 and 4 only and having length at max… Read More »

## Find the shortest distance between any pair of two different good nodes

Given a weighted undirected connected graph with N nodes and M edges. Some of the nodes are marked as good. The task is to find… Read More »

## Ways to place 4 items in n^2 positions such that no row/column contains more than one

Given an integer N where 4 ≤ N ≤ 100. There are N lines vertically and N lines horizontally. So, There are N2 intersections. The… Read More »

## Print all the sum pairs which occur maximum number of times

Given an array arr[] of N distinct integers. The task is to find the sum of two array integers a[i] + a[j] which occurs maximum… Read More »

## Maximize the summation of numbers in a maximum of K moves in range [L, R]

Given an array arr[] of N integers and Q queries. Each query consists of 3 integers L, R and K. You can move from index… Read More »

## Smallest divisor D of N such that gcd(D, M) is greater than 1

Given two positive integers N and M., The task is to find the smallest divisor D of N such that gcd(D, M) > 1. If… Read More »

## Count numbers which are divisible by all the numbers from 2 to 10

Given an integer N, the task is to find the count of numbers from 1 to N which are divisible by all the numbers from… Read More »

## Print direction of moves such that you stay within the [-k, +k] boundary

Given an array arr[] of N positive integers and an integer K. It is given that you start at position 0 and you can move… Read More »