Skiing on Mountains Matrix : “John Snow” likes Skiing on Mountains a lot.That’s not very surprising, since skiing is really great. The problem with skiing is one have to slide downwards to gain speed. Also … Read More
Interview Questions
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
The greedy coins game Dynamic Programming
The greedy coins game Dynamic Programming Solution :
Question statement There is a row of 2n coins on the table; each coin can have any positive integer value. Two players alternate turns.
On a player’s … 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
Maximum occurred Smallest integer in n ranges
Maximum occurred integer in n ranges
Given n ranges in the form of Start Number and End Number in Two Array L and R such that
L[i]-R[i] is one range given. Our task is to … Read More
Best Java Book | Top Java Programming Book for Beginners
Right view of Binary tree
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 … Read More
Find Nearest Minimum number in left side in O(n)
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,… Read More