## Find k numbers with most occurrences in the given array

Given an array of n numbers and a positive integer k. The problem is to find k numbers with most occurrences, i.e., the top k… Read More »

## Find median of BST in O(n) time and O(1) space

Given a Binary Search Tree, find median of it. If no. of nodes are even: then median = ((n/2th node + (n+1)/2th node) /2 If… Read More »

## Find Second largest element in an array

Given an array of integers, our task is to write a program that efficiently finds the second largest element present in the array. Example: Input… Read More »

## k-th smallest absolute difference of two elements in an array

We are given an array of size n containing positive integers. The absolute difference between values at indices i and j is |a[i] – a[j]|.… Read More »

## Find k pairs with smallest sums in two arrays

Given two integer arrays arr1[] and arr2[] sorted in ascending order and an integer k. Find k pairs with smallest sums such that one element… Read More »

## Find all elements in array which have at-least two greater elements

Given an array of n distinct elements, the task is to find all elements in array which have at-least two greater elements than themselves. Examples… Read More »

## Sum of k smallest elements in BST

Given Binary Search Tree. The task is to find sum of all elements smaller than and equal to Kth smallest element. Examples: Input : K… Read More »

## k’th heaviest adjacent node in a graph where each vertex has weight

Given a positive number k and an undirected graph of N nodes, numbered from 0 to N-1, each having a weight associated with it. Note… Read More »

## Find the largest three elements in an array

Given an array with all distinct elements, find the largest three elements. Expected time complexity is O(n) and extra space is O(1). Examples : Input:… Read More »

## K’th smallest element in BST using O(1) Extra Space

Given a Binary Search Tree (BST) and a positive integer k, find the k’th smallest element in the Binary Search Tree. For example, in the… Read More »

## K’th largest element in a stream

Given an infinite stream of integers, find the k’th largest element at any point of time. Example: Input: stream[] = {10, 20, 11, 70, 50,… Read More »

## K’th Largest Element in BST when modification to BST is not allowed

Given a Binary Search Tree (BST) and a positive integer k, find the k’th largest element in the Binary Search Tree. For example, in the… Read More »

## K’th Smallest/Largest Element in Unsorted Array | Set 3 (Worst Case Linear Time)

We recommend reading following posts as a prerequisite of this post. K’th Smallest/Largest Element in Unsorted Array | Set 1 K’th Smallest/Largest Element in Unsorted… Read More »

## K’th Smallest/Largest Element in Unsorted Array | Set 2 (Expected Linear Time)

We recommend reading following post as a prerequisite of this post. K’th Smallest/Largest Element in Unsorted Array | Set 1 Given an array and a… Read More »

## K’th Smallest/Largest Element in Unsorted Array | Set 2 (Expected Linear Time)

We recommend to read following post as a prerequisite of this post. K’th Smallest/Largest Element in Unsorted Array | Set 1 Given an array and… Read More »