Given a non-empty binary tree, find the maximum path sum.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child … Read More

Interview Questions asked in Google, Microsoft, Amazon

Given a non-empty binary tree, find the maximum path sum.

For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child … Read More

by Dhaval Dave

Find shortest distances between every pair of vertices in a given edge weighted directed Graph.

**Input:**

The first line of input contains an integer T denoting the no of test cases . Then T test … Read More

by Dhaval Dave

Given a Binary Tree, print the diagonal traversal of the binary tree

Consider lines of slope -1 passing between nodes. Given a Binary Tree, print all diagonal elements in a binary tree belonging to same … Read More

by Dhaval Dave

Number Theory is used a lot for solving real world problems and for the same reason It’s asked most of the time in interviews. This article marks the beginning of series of articles over Number … Read More

by Dhaval Dave

**Knight Tour Problem** : Given a chess board of size n x n, initial position of knight and final position of knight. We need to find the minimum number of steps required to reach final … Read More

by Dhaval Dave

Consider a binary matrix as shown in the figure below. You need to find the maximum size of square sub matrix with all 1’s.

… Read Moreby Dhaval Dave

Given two strings x and y, What is the cheapest possible way to convert x into y where following operations are allowed to perform –

- Substitute a character c of x with c’.
- Insert

by Dhaval Dave

In a Binary Search Tree (BST), all keys in left subtree of a key must be smaller and all keys in right subtree must be greater. So a Binary Search Tree by definition has distinct … Read More

by Dhaval Dave

Given a string, find the minimum number of characters to be inserted to form Palindrome string out of given string

Before we go further, let us understand with few examples:

ab: Number of insertions required … Read More

by Dhaval Dave

Find weather two given trees are isomorphic to each other or not.

Lets understand What is isomorphic strings

AAB and XXY are IsoMorphic to each other, consider A replaces/morphs as X and B as Y, … Read More