# Category Archives: Algorithms

## Largest subset with M as smallest missing number

Given an array arr[] of N positive integers and a positive integer M, the task is to find the length of longest subset whose smallest… Read More »

## Print negative weight cycle in a Directed Graph

Given a weighted directed graph consisting of V vertices and E edges. The task is to print the cyclic path whose sum of weight is… Read More »

## Difference between sum of even and odd valued nodes in a Binary Tree

Given a binary tree, the task is to find the absolute difference between the even valued and the odd valued nodes in a binary tree.… Read More »

## Count of all subsequences having adjacent elements with different parity

Given an array arr[] of size N, the task is to find the number of non-empty subsequences from the given array such that no two… Read More »

## Find the node at the centre of an N-ary tree

Prerequisites: Diameter of a N-ary tree Path between two nodes in a graph Given a N-ary tree with N nodes numbered from 0 to N-1… Read More »

## Count of submatrix with sum X in a given Matrix

Given a matrix of size N x M and an integer X, the task is to find the number of sub-squares in the matrix with… Read More »

## Rearrange an array such that product of every two consecutive elements is a multiple of 4

Given an array arr[] of size N, the task is to rearrange the array elements such that for every index i(1 <= i <= N… Read More »

## Maximal independent set from a given Graph using Backtracking

Given an undirected graph with V vertices and E edges, the task is to print all the independent sets and also find the maximal independent… Read More »

## Sum of Hamming difference of consecutive numbers from 0 to N | Set 2

Given a number N, the task is to find the sum of Hamming difference of consecutive numbers from 0 to N. Hamming Distance between two… Read More »

## Check if a decreasing Array can be sorted using Triple cyclic shift

Given an arr[] of size N whose elements are sorted in descending order. The task is to find if the given array can be sorted… Read More »

## Square root of a number by Repeated Subtraction method

Given an integer N, the task is to find its perfect square root by repeated subtraction only. Examples: Input: N = 25 Output: 5 Input:… Read More »

## Maximum inversions in a sequence of 1 to N after performing given operations at most K times

Given two integers N and K, the task is to find the maximum number of inversion in a sequence of first N natural numbers after… Read More »

## Check if N can be obtained by repetitive addition or subtraction of two given numbers

Given three positive integers N, A, and B, the task is to check if it is possible to obtain N by adding or subtracting A… Read More »

## Maximize count of distinct elements possible in an Array from the given operation

Given an array A[] of size N, the task is to maximize the count of distinct elements in the array by inserting the absolute differences… Read More »

## Check if two arrays can be made equal by reversing any subarray once

Given two arrays A[] and B[] of equal size N, the task is to check whether A[] can be made equal to B[] by reversing… Read More »