##
Highway Billboard Problem
March 13, 2017

Consider a highway of M miles. The task is to place billboards on the highway such that revenue is maximized. The possible sites for billboards… Read More »

March 13, 2017

Consider a highway of M miles. The task is to place billboards on the highway such that revenue is maximized. The possible sites for billboards… Read More »

Given a permutation of first n natural numbers as array and an integer k. Print the lexicographically largest permutation after at most k swaps Input:… Read More »

March 12, 2017

Given an array of size n and integer k, count all pairs in array which differ in exactly K bits of binary representation of both… Read More »

Given a positive integer N. The task is to find the number of ways of representing N as a sum of 1s and 2s. Examples:… Read More »

Given an array of n elements. Consider array as circular array i.e element after an is a1. The task is to find maximum sum of… Read More »

March 11, 2017

Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands.

Given an array of integers (both odd and even), sort them in such a way that the first part of the array contains odd numbers… Read More »

Given a number N, find sum of all GCDs that can be formed by selecting all the pairs from 1 to N. Input : 4… Read More »

March 10, 2017

We can calculate the prime factorization of a number “n” in O(sqrt(n)) as discussed here. But O(sqrt n) method times out when we need to… Read More »

Given a array of both positive and negative integers ‘arr[]’ which are sorted. Task is to sort square of the numbers of the Array. Examples:… Read More »

March 9, 2017

A Seed of a number n is a number x such that multiplication of x with its digits is equal to n. The task is… Read More »

A Cullen Number is a number of the form is 2n * n + 1 where n is an integer. The first few Cullen numbers… Read More »

March 8, 2017

Given a positive number K, we need to permute first N natural numbers in such a way that absolute distance of each permuted number from… Read More »

March 7, 2017

Given an array arr[], find nearest element for every element such that there is at least one common prime factor. In output, we need to… Read More »

Given an integer N. The task is to find a number that is smaller than or equal to N and has maximum prime factors. In… Read More »