# Category Archives: Algorithm

## Stable Selection SortOctober 4, 2017

A sorting algorithm is said to be stable if two objects with equal or same keys appear in the same order in sorted output as… Read More »

## Unique element in an array where all elements occur k times except oneOctober 3, 2017

Given an array which contains all elements occurring k times, but one occurs only once. Find that unique element. Examples: Input : arr[] = {6,… Read More »

## Print all subsets of given size of a set

Generate all possible subset of size r of given array with distinct elements. Examples: Input : arr[] = {1, 2, 3, 4} r = 2… Read More »

## Find Unique pair in an array with pairs of numbers

Given an array where every element appears twice except a pair (two elements). Find the elements of this unique pair. Examples: Input : 6, 1,… Read More »

## Number of ways to arrange N items under given constraintsOctober 2, 2017

We are given N items which are of total K different colors. Items of the same color are indistinguishable and colors can be numbered from… Read More »

## Product of factors of number

Given a number n, find the product of all factors of n. Since the product can be very large answer it modulo 10^9 + 7.… Read More »

## Decimal representation of given binary string is divisible by 10 or not

The problem is to check whether the decimal representation of the given binary number is divisible by 10 or not. Take care, the number could… Read More »

## Longest Increasing Path in Matrix

Given a matrix of N rows and M columns. From m[i][j], we can move to m[i+1][j], if m[i+1][j] > m[i][j], or can move to m[i][j+1]… Read More »

## Program to count digits in an integer (3 Different Methods)

Count the number of digits in a long integer entered by a user. Recommended: Please try your approach on {IDE} first, before moving on to… Read More »

## Minimum cells required to reach destination with jumps equal to cell valuesOctober 1, 2017

Given a m x n matrix mat[][] containing positive integers. The problem is to reach to the cell (m-1, n-1) from the cell (0, 0)… Read More »

## To check whether a large number is divisible by 7

You are given an n-digit large number, you have to check whether it is divisible by 7. A (r+1)-digit integer n whose digital form is… Read More »

## Maximum points from top left of matrix to bottom right and return back

Given a matrix of size N X M consisting of ‘#’, ‘.’ and ‘*’. ‘#’ means blocked path, ‘.’ means walkable path and ‘*’ means… Read More »

## Print all leaf nodes of a Binary Tree from left to rightSeptember 30, 2017

Given a binary tree, we need to write a program to print all leaf nodes of the given binary tree from left to right. That… Read More »

## Check whether the number has only first and last bits set

Given a positive integer n. The problem is to check whether only the first and last bits are set in the binary representation of n.… Read More »

## Tribonacci Numbers

The tribonacci series is a generalization of the Fibonacci sequence where each term is the sum of the three preceding terms. The Tribonacci Sequence :… Read More »