# Category Archives: Algorithms

When you wish to say something but miss a few characters/words, the first response that anyone gives you is “Did you mean this?“. The same… Read More
Given a tree with N nodes, an array A[] of size N denoting the value of each node and array edges [][] of size (N-1),… Read More
Given two arrays A[] and B[] of size N each, the task is to find the number of elements in array B[] that occur before… Read More
Given a 2-D array A[][] of size N × 3, where each element of the array is of the form {x, y, z}, where x,… Read More
Given an input arr[] of length N, Which contains integers from 1 to N in unsorted order. You can apply only one type of operation… Read More
Given an array A consisting of N positive integers and for any ordered triplet( i, j, k) such that i, j, and k are all… Read More
Given a set S of having numbers 1, 2, 3, . . ., N, and an integer K, the task is to form a set… Read More
Given an integer array arr[] of length N and an integer K, the task is to rearrange the elements of arr[] in such a way… Read More
Given an integer N(1 ≤ N ≤ 500), Construct an integer arr[] of length N, such that it should follow all the given conditions below: … Read More
In a party of N people, each person is denoted by an integer. Couples are represented by the same number. Find out the only single… Read More
Given an array A[] of length N, the task is to find the total number of distinct pairs (i, j) of indices where 1 ≤… Read More
Given an array A[] consisting of N elements, the task is to find the minimum length of the subarray starting from each index and the… Read More
Given an array A[] of size N such that every element is a positive power of 2. In one operation, choose a non-empty subsequence of… Read More
To understand this let’s take a binary tree Binary tree If we conduct BFS in this tree: In level 0 there is one node in… Read More
BFS and DFS are two algorithms that we use for graph traversal. In both the algorithms we start from a node and iterate over the… Read More