## Weighted Prefix Search

Given n strings and a weight associated with each string. The task is to find the maximum weight of string having the given prefix. Print… Read More »

Given n strings and a weight associated with each string. The task is to find the maximum weight of string having the given prefix. Print… Read More »

In previous posts, we have discussed how to calculate the Lowest Common Ancestor (LCA) for a binary tree and a binary search tree (this, this… Read More »

Given a Binary Matrix. The task is to find the pair of row in the Binary matrix that has maximum bit difference Examples: Input: mat[][]… Read More »

Given a string of length n of lowercase alphabet characters, we need to count total number of distinct substrings of this string. Examples: Input :… Read More »

Given a matrix A of size NxN, we need to find the number of inversion pairs in it. Inversion count in a matrix is defined… Read More »

Given an array of integers, find the minimum (or maximum) element and the element just greater (or smaller) than that in less than 2n comparisons.… Read More »

Given a matrix of size M x N, there are large number of queries to find submatrix sums. Inputs to queries are left top and… Read More »

Like array and linked list, unrolled Linked List is also a linear data structure and is a variant of linked list. Unlike simple linked list,… Read More »

Let us consider the below problem statement and think of different solutions for it. Given a set S of elements such that the elements are… Read More »

Given a list of contacts which exist in a phone directory. The task is to implement search query for the phone directory. The search query… Read More »

Given an array arr[0..n-1]. The following operations need to be performed. update(l, r, val) : Add ‘val’ to all the elements in the array from… Read More »

Given a size n in which initially all elements are 0. The task is to perform multiple multiple queries of following two types. The queries… Read More »

Given an array arr[0 . . . n-1]. We need to efficiently find the minimum and maximum value from index qs (query start) to qe… Read More »