Count of distinct substrings of a string using Suffix ArrayJanuary 10, 2017

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 »

Count inversion pairs in a matrixJanuary 7, 2017

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 »

Second minimum element using minimum comparisonsDecember 21, 2016

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 »

Count of distinct substrings of a string using Suffix TrieNovember 30, 2016

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 »

Summed Area Table – Submatrix SummationNovember 24, 2016

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 »

Unrolled Linked List | Set 1 (Introduction)October 18, 2016

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 »

proto van Emde Boas Trees | Set 1 (Background and Introduction)October 10, 2016

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 »

Implement a Phone DirectoryOctober 9, 2016

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 »

Binary Indexed Tree : Range Update and Range QueriesOctober 6, 2016

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 »

Count and Toggle Queries on a Binary ArrayOctober 1, 2016

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 »

Binary Indexed Tree : Range Updates and Point QueriesSeptember 30, 2016

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 »

Min-Max Range Queries in ArraySeptember 11, 2016

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 »

Print all words matching a pattern in CamelCase Notation DictonaryAugust 9, 2016

Given a dictionary of words where each word follows CamelCase notation, print all words in the dictionary that match with a given pattern consisting of… Read More »

Range LCM QueriesJuly 26, 2016

Given an array of integers, evaluate queries of the form LCM(l, r). There might be many queries, hence evaluate the queries efficiently. LCM (l, r)… Read More »

Querying the number of distinct colors in a subtree of a colored tree using BITJuly 24, 2016

Prerequisites : BIT, DFS Given a rooted tree T, with ‘n’ nodes, each node has a color denoted by the array color[](color[i] denotes the color… Read More »