# 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

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

Write a code to Convert number to words . example ip 15 op : fifteen

ip : 1234 op : one thousand and thirty four

Algorithm : When we detect a number at any place how to convert to a word. Obviously we need to store it.

See usage of Data Structure in java and Data Structure in c++ .

See usage of static string in java.

Step 1 ) Create array of ones[20] = {“zero”, “one”, “two”, …, “nineteen”};

Step 2) Create array of tens[10] = {“”, “ten”, “twenty”, …, “ninety”}; [Read more…]

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

Last Updated on by Dhaval Dave

Here We have implemented a Generic Stack Example with Templates in C++ where we can Push any element into stack.

#include <iostream>

#include <vector>

#include <cstdlib>

#include <string>

#include <stdexcept>

using namespace std;

Last Updated on by Dhaval Dave

Couple of years ago when me and my friends appeared for campus interviews in IITs, NITs and BITs we faced many challenging interview questions like *N petrol bunks arranged in a city, Sort Stack in place etc.*

This article we are focusing more on MTech because of several reasons, which you’ll shortly find.

Start preparing for campus selection from day 1 of your college, try to utilize all facility and free time to build your knowledge.

Reason is Btech students staying in campus have proper understanding from super seniors and seniors about type of questions and Seniors would have guided them how to prepare for campus, so they would be almost ready for interviews when you join MTech course.

So its better to start preparing with them instead of waiting till pre-campus selection vacations.

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