Convert a Binary Tree to a Doubly Linked List

The structure of Node of a Binary Tree and Doubly linked list are same. struct Node { int data; Node* left; Node* right; }  Structure […]

Maximum XOR value of two elements

Given an array of numbers find the maximum XOR value of two numbers in the array. Input Array = {12, 15, 5, 1, 7, 9, […]

Print all words in a Trie data structure

Given a collection of words stored in a Trie data structure, write a function that print all the words stored in it. For example, If […]

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 […]