Skip to content

# Category Archives: Algorithms

The Recursion Tree Method is a way of solving recurrence relations. In this method, a recurrence relation is converted into recursive trees. Each node represents… Read More
Given an N-array Tree consisting of N nodes and an integer K, the task is to find the Kth largest element in the given N-ary… Read More
Given two positive integers N and K, initialize an empty array arr[] and Q number of queries of the following two types: addInteger(x): Insert element… Read More
Given an array arr[] consisting of N positive integers, the task is to find the sum of Bitwise AND of all possible triplets (arr[i], arr[j],… Read More
Given an array arr[] consisting of N integers, the task is to find the number of pairs, where i ≤ j, such that the sum… Read More
Given a string S consisting of N lowercase characters, the task is to modify the given string such that no subsequence of length two repeats… Read More
Given an array arr[] consisting of N pairs and a positive integer M, the task is to maximize the average of the ratio of the… Read More
Given a positive integer N, the task is to count the number of different bases in which, when N is represented, the most significant bit… Read More
Given a numeric string S consisting of N digits and a positive integer K, the task is to check if the given string can be… Read More
Given a positive integer N, the task is to print all the numbers, say K, such that K is a divisor of N and K… Read More
Given an array A[] of size N, and two numbers K and D, the task is to calculate the maximum subset-sum divisible by D possible… Read More
Given an array A[] of N positive numbers, the task is to find the maximum sum that can be formed which has no three consecutive… Read More
In computational complexity theory, the Cook–Levin theorem, also known as Cook’s theorem, states that the Boolean satisfiability problem is NP-complete. That is, it is in… Read More
Given a Binary Tree consisting of N nodes, the task is to first compress the tree diagonally to get a list of integers and then,… Read More
Given a circular singly linked list, the task is to print the next greater element for each node in the linked list. If there is… Read More