Merge 2 Binary Search Trees
Write a program to mergeĀ two binary search trees, in O(n) time with O(1) space
Just another WordPress weblog
Archive for the ‘Job Interviews’ Category.
Write a program to mergeĀ two binary search trees, in O(n) time with O(1) space
Given a tree with only children pointing to the parents, find the least common ancestor of 2 nodes.
How would you find a cycle in a linked list? Optimize for speed.
One of the common, yet tricky interview question is to find the lowest common ancestor node for given 2 nodes in
A. Binary Tree
B. N-ary tree
Find the maximum rectangle completely contained inside a histogram where each bars has a width of 1 unit. The heights of the bars of the histograms are given in an array e.g. {4,2,10,8,12,13,15,8,6} and they have a fixed width w = 1, say. The rectangles formed here are: 4X1, 2X9, 10X1, 8X6, 12X3, 13X2, 15X1, 8X6, 6X7 Thus, max-area rectangle = 8X6 = 48
Find the longest palindrome in a given string
Given a String, find out all the valid dictionary words contained in the string.
Write a program to reverse a linked list
1. With recursion
2. Without Recursion
Given a array of 0’s,1’s and 2’s. Sort the array.
Find Median of 2 sorted arrays