# Maximum size of square sub matrix with all 1

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.

Interview Questions and Discussion in Google, Microsoft, Amazon, Walmart

Last Updated on by Abhey Rana Leave a Comment

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.

Last Updated on by Abhey Rana Leave a Comment

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 a character in x.
- Delete a character from x.

Each of these operations may have a cost associated with them. For example we may have a 26*26 matrix which can have a cost of substituting one character with another character. In a similar manner we may have a 26*2 matrix which can have cost of inserting and deleting a character.

Last Updated on 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 keys and duplicates in binary search tree are not allowed.

How to allow duplicates where every insertion inserts one more key with a value and every deletion deletes one occurrence?

A **Simple Solution** is to allow same keys with count. For example consider insertion of keys 3, 6, 7, 8, 8, 8, 10, 12, 12 in an empty Binary Search Tree [Read more…]

Last Updated on 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 is 1. **b**ab

aa: Number of insertions required is 0. aa

[Read more…]

Last Updated on 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, then both strings are isomorphic.

ABC and XXY are not IsoMorphic.

[Read more…]

Last Updated on by Dhaval Dave

We are given a Binary Tree, Print the Right view of Binary tree,

Right view of binary tree is : List of all nodes which are visible If you look at Binary tree from right side.

For example,

Right view of following tree is a, c, g, h a / \ b c / \ / \ d e f g \ h

Hint for logic : [Read more…]

Last Updated on by Dhaval Dave

Given an array of integers, find the nearest smaller number for every element such that the smaller element is on left side.

Examples:

Input: arr[] = {1, 6, 4, 10, 2, 5} Output: {-1, 1, 1, 4, 1, 2} First element ('1') has no element on left side. For 6, there is only one smaller element on left side '1'. For 10, there are three smaller elements on left side (1, 6 and 4), nearest among the three elements is 4. Input: arr[] = {1, 3, 0, 2, 5} Output: {-1,1,-1, 0, 2}

Last Updated on by Dhaval Dave

(Below is the table of price rule) Come up with data structure you can store these price rules PriceRule

Price Rules:

On Weekday On Weekend

Hours Price Hours Price

0 – 2 $5 0 – 2 $8

2 – 6 $10 2 – 6 $13

6 – 12 $15 6 – 12 $18

12 – 24 $20 12 – 24 $25

2 The interviewer asked to come up with an architecture for a system which shows the parking spaces available near customers’ location in a mobile app.

Lets start with 1). What is correct way to store Prices.

Last Updated on by Dhaval Dave

If a binary tree is given, how to find Maximum path sum between two leaves of binary tree.

All should be numbers The maximum sum path may or may not go through root. For example, in the following binary tree, the maximum sum is 27(3 + 6 + 9 + 0 – 1 + 10). Expected time complexity is O(n). Algorithm : 1) We need sum for left and right binary sub tree. |

Last Updated on by Dhaval Dave

Set of Numbers are given to you.

convert them to Roman numbers.

Solution is in Hacker Earth style [Read more…]

- 1
- 2
- 3
- …
- 7
- Next Page »