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
Amazon Interview Question
Closed Parentheses checker
Problem Statement:
You are given 3 types of parentheses (),{},[]. Now you are supposed to check whether a given string containing some parentheses is closed or not.
Regular Expression Matching
You are given a string T which consists of 0’s and 1’s. Now you input two non-empty strings U and V. Then your task is to match the Regular Expression – U*V with the given … Read More
Knight Tour Problem (Graph – Breadth First Search)
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
Maximum size of square sub matrix with all 1’s in a binary matrix
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.
… Read MoreEdit Distance ( Dynamic Programming )
Problem
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
Trapping Rain Water
Trapping Rain Water or Water collected between towers : Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after … Read More
Handle duplicates in Binary Search Tree
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
Minimum insertions to form a palindrome
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
Binary Tree Isomorphic to each other
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