Trie data structure

String matching is a big research area and there are many data structure (eg. B-Tree, HashMap, Set) that help indexing of strings. There are also many algorithms […]

Longest consecutive path in a Binary tree

Given a Binary tree, write code to find the length of longest path such that value of node in that path are consecutive and in decreasing […]

Rectangles in a matrix

Given a character matrix in which some of the cells have alphabets written on them while other cells are empty (empty cells contains character ‘-‘ […]

Sum of rectangle region in a given matrix

Given a matrix of integers of order M*N and coordinates of a rectangular region in the matrix, write code to find the sum of all […]

Putting blocks at largest distance from each other in a row

Given a row (linear), two blocks are placed at each end and there are n empty positions between then. If ‘B’ represent block and n […]

Nearest number with non-decreasing digits

Given a number N given in the form of array, with each index storing one digit of the number. Write code to change the number […]

8 queens problem

This problem is to place 8 queens on the chess board so that they do not check each other. It can be asked in two […]

Flip all zeros to ones

Given a string of bits and a number k. In one flip, you can toggle k consecutive characters, how many flips are required to change the entire string […]

Sum of all nodes at a vertical level

Given a binary tree and a number n representing the vertical level. Write code to compute the sum of all nodes which are at vertical […]

Vertical distance of a Node from root

Given a Binary Tree and a Node, Write a function that return the vertical distance of that node from root of the tree. The vertical […]