# Category Archives: Algorithms

## Minimum distance between the maximum and minimum element of a given Array

Given an array A[] consisting of N elements, the task is to find the minimum distance between the minimum and the maximum element of the… Read More »

## Menu-Driven program for Phone Directory

Problem Statement: Write a menu-driven program for using switch-case with following features: Store Contact numbers of people Search for the Contact numbers using their names… Read More »

## Puzzle | Connect 9 circles each arranged at center of a Matrix using 3 straight lines

Consider 9 circles each arranged at the center of cells of a 2-D matrix of shape 3*3. Draw 3 straight lines without removing pen from… Read More »

## Local and Global Optimum in Uni-variate Optimization

Uni-variate optimization is a simple case of a non-linear optimization problem with an unconstrained case that is there is no constraint. Uni-variate optimization may be… Read More »

## Converting Power Law Distribution to a Linear graph

Whenever we are working on ML projects, we have to deal with the high dimensionality of the dataset. There is a very particular term to… Read More »

## Check whether every node of binary tree has a value K on itself or its any immediate neighbours

Given a binary tree and a value K, the task is to check if every node of the binary tree has either value of the… Read More »

## Count of root to leaf paths in a Binary Tree that form an AP

Given a Binary Tree, the task is to count all paths from root to leaf which forms an Arithmetic Progression. Examples:  Input:   Output: 2 Explanation: The paths… Read More »

## Kth Smallest element in a Perfect Binary Search Tree

Given a Perfect BST with N nodes and an integer K, the task is to find the Kth smallest element in present in the tree.… Read More »

## Longest alternating subsequence with maximum sum | Set 2

Given an array arr[] of size N, consisting of positive and negative integers, the task is to find the longest alternating subsequence(i.e. the sign of… Read More »

## Product of divisors of a number from a given list of its prime factors

Given an array arr[] representing a list of prime factors of a given number, the task is to find the product of divisors of that… Read More »

## Count of binary strings of length N having equal count of 0’s and 1’s

Given an integer N, the task is to find the number of binary strings possible of length N having same frequency of 0s and 1s.… Read More »

## Check if an array can be split into subsets of K consecutive elements

Given an array arr[] and integer K, the task is to split the array into subsets of size K, such that each subset consists of… Read More »

## Length of longest subsequence whose XOR value is odd

Given an array arr[] of N positive integers, the task is to find the length of the longest subsequence such that Bitwise XOR of all… Read More »

## Minimum changes required to make each path in a matrix palindrome

Given a matrix with N rows and M columns, the task is make all possible paths from the cell (N, M) to (1, 1) palindrome… Read More »

## Lexicographical smallest number after at most K consecutive swaps

Given a number in form of string str and an integer K, the task is to find the smallest integer that can be formed after… Read More »