# Category Archives: Algorithms

## Count of ways to select K consecutive empty cells from a given Matrix

Given a binary matrix V[][] of dimensions N * M, wherein each cell is either empty or blocked marked by a 0 and 1 respectively,… Read More »

## Flattening a linked list | Set 2

Given a linked list where every node represents a linked list and contains two pointers of its type: Pointer to next node in the main… Read More »

## Check if a string can be split into substrings starting with N followed by N characters

Given a string str, the task is to check if it can be split into substrings such that each substring starts with a numeric value… Read More »

## Largest number made up of X and Y with count of X divisible by Y and of Y by X

Given three integers X, Y and N, the task is to find the largest number possible of length N consisting only of X and Y… Read More »

## Count quadruplets(A, B, C, D) till N such that sum of square of A and B is equal to that of C and D

Given a number N, the task is to find the number of quadraples such that a2 + b2 = c2 + d2 where (1 <=… Read More »

## Minimum count of numbers required with unit digit X that sums up to N

Given two integers N and X, the task is to find the minimum count of integers with sum N and having unit digit X. If… Read More »

## Maximum bitwise OR value of subsequence of length K

Given an array arr[] of N positive integers and a number K, the task is to find the maximum value of bitwise OR of the… Read More »

## Sum of all divisors from 1 to N | Set 3

Given a positive integer N, the task is to find the sum of divisors of all the numbers from 1 to N. Examples: Input: N… Read More »

## Check if a graph is Strongly, Unilaterally or Weakly connected

Given an unweighted directed graph G as a path matrix, the task is to find out if the graph is Strongly Connected or Unilaterally Connected… Read More »

## Maximum cost path in an Undirected Graph such that no edge is visited twice in a row

Given an undirected graph having N vertices and M edges and each vertex is associated with a cost and a source vertex S is given.… Read More »

## Reverse a subarray of the given array to minimize the sum of elements at even position

Given an array arr[] of positive integers. The task is to reverse a subarray to minimize the sum of elements at even places and print… Read More »

## Print the longest path from root to leaf in a Binary tree

Given a binary tree, the task is to print the longest path from the root node to the leaf node. If there are multiple answers… Read More »

## Represent K as sum of N-bonacci numbers

Given two numbers K and N. The task is to represent the given number K as a sum of several N-bonacci numbers. Examples: Input: K… Read More »

## Minimize sum of smallest elements from K subsequences of length L

Given an array arr[] of size N, the task is to find the minimum possible sum by extracting the smallest element from any K subsequences… Read More »

## Count of numbers upto N digits formed using digits 0 to K-1 without any adjacent 0s

Given two integers N and K, the task is to count the numbers up to N digits such that no two zeros are adjacents and… Read More »