# Category Archives: Algorithms (adsbygoogle = window.adsbygoogle || []).push({});

## Maximum number of region in which N non-parallel lines can divide a plane

Given N‘, the number of non-parallel lines. The task is to find the maximum number of regions in which these lines can divide a plane.… Read More »

## 21 Matchsticks Problem

Given 21 Matchsticks and 2 users, A and B (computer and user respectively). Users can pick matchsticks not more than four at a time. The… Read More »

## Minimum Possible sum of digits in a positive multiple of N

Given a number N, find the minimum possible sum of digits that can be obtained from a positive Multiple of N. Constraints : 1<=N<=10^5. Examples:… Read More »

## Find the smallest positive number which can not be represented by given digits

Given an array arr[] of size 10 where arr[i] represents the frequency of the digit i. The task is to find the smallest positive number… Read More »

## Find the average of k digits from the beginning and l digits from the end of the given number

Given three integers N, K and L. The task is to find the average of the first K digits and the last L digits of… Read More »

## Count Set-bits of number using Recursion

Given a number N. The task is to find the number of set bits in its binary representation using recursion. Examples: Input : 21 Output… Read More »

## Number of possible permutations when absolute difference between number of elements to the right and left are given

Given an array of N elements where each element i, the absolute difference between total elements to the right and left of it are given.… Read More »

## Check whether two points (x1, y1) and (x2, y2) lie on same side of a given line or not

Given three integers a, b and c which represents coefficients of the equation of a line a * x + b * y – c… Read More »

## Find the area of quadrilateral when diagonal and the perpendiculars to it from opposite vertices are given

Given three integers d, h1, h2 where d represents the length of the diagonal of a quadrilateral. h1 and h2 represents the lengths of the… Read More »

## Print N terms of Withoff Sequence

Wythoff array is an infinite matrix of integers derived from the Fibonacci sequence. Every positive integer in the matrix occurs only once. Wythoff array: 1… Read More »

## Number of Subsequences with Even and Odd Sum

Given an array, find the number of subsequences whose sum is even and the number of subsequences whose sum is odd. Example : Input: arr[]… Read More »

## Find minimum changes required in an array for it to contain k distinct elements

Given an array arr of size N and a number K. The task is to find the minimum elements to be replaced in the array… Read More »

## Find the maximum cost path from the bottom-left corner to the top-right corner

Given a two dimensional grid, each cell of which contains integer cost which represents a cost to traverse through that cell. The task is to… Read More »

## Count smaller elements on right side and greater elements on left side using Binary Index Tree

Given an array arr[] of size N. The task is to find smaller elements on the right side and greater elements on the left side… Read More »

## Program to find the Nth Prime Number

Given an integer N. The task is to find the Nth prime number. Examples: Input : 5 Output : 11 Input : 16 Output :… Read More »