## Minimum operations required to change the array such that |arr[i] – M| <= 1

Given an array[] of integers, the task is find the minimum number of operations required to change the array elements such that for any positive… Read More »

## Print characters having odd frequencies in order of occurrence

Given a string str containing only lowercase characters. The task is to print the characters having an odd frequency in the order of their occurrence.… Read More »

## Smallest multiple of N formed using the given set of digits

Given a set of digits S and an integer N, the task is to find the smallest positive integer if exists which contains only the… Read More »

## Compare sum of first N-1 elements to Nth element of an array

Given an array arr[] of size N, the task is to check whether the sum of first N – 1 element of the array is… Read More »

## Find the lexicographically smallest sequence which can be formed by re-arranging elements of second array

Given two arrays A and B of N integers. Reorder the elements of B in itself in such a way that the sequence formed by… Read More »

## Kth largest node among all directly connected nodes to the given node in an undirected graph

Given two arrays u and v, representing a graph such that there is an undirected edge from u[i] to v[i] (0 ≤ v[i], u[i] <… Read More »

## Count number of subsets whose median is also present in the same subset

Given an array arr[] of size N, the task is to count the number of ways we can select a subset from the given array… Read More »

## Find sub-arrays from given two arrays such that they have equal sum

Given two arrays A[] and B[] of equal sizes i.e. N containing integers from 1 to N. The task is to find sub-arrays from the… Read More »

## Find an index such that difference between product of elements before and after it is minimum

Given an integer arr[], the task is to find an index such that the difference between the product of elements up to that index and… Read More »

## Maximum Sum SubArray using Divide and Conquer | Set 2

Given an array arr[] of integers, the task is to find the maximum sum sub-array among all the possible sub-arrays. Examples: Input: arr[] = {-2,… Read More »

## Index of kth set bit in a binary array with update queries

Given a binary array arr[] and q queries of following types: k: find the index of the kth set bit i.e. kth 1 in the… Read More »

## Check if given Preorder, Inorder and Postorder traversals are of same tree | Set 2

Given Preorder, Inorder and Postorder traversals of some tree. The task is to check if they all are of the same tree. Examples: Input :… Read More »

## Number of positions such that adding K to the element is greater than sum of all other elements

Given an array arr[] and a number K. The task is to find out the number of valid positions i such that (arr[i] + K)… Read More »

## LRU Approximation (Second Chance Algorithm)

If you are not familiar with Least Recently Used Algorithm, check Least Recently Used Algorithm(Page Replacement) This algorithm is a combination of using a queue,… Read More »

## Find k closest numbers in an unsorted array

Given an unsorted array and two numbers x and k, find k closest values to x. Examples: Input : arr[] = {10, 2, 14, 4,… Read More »