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 ‘Microsoft’ 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
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.
Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1. example if S1=ABCD then BCDA,CDAB etc are rotations of S1.
Given a Binary Search Tree, write a program to print the kth smallest element
This is a very common interview questions and comes in various forms. The most common one is of the following format
Problem 1
Given an array of 999 distinct integers ranging from 1 to 1000 including. Find which number is missing. Restrictions: loop over the array only once, can’t allocate an additional array.
Another version of the problem is where 2 numbers are missing.
Problem 2
Given an array of 998 distinct integers ranging from 1 to 1000 including. Find which 2 numbers are missing.
Restrictions: loop over the array only once, can’t allocate an additional array.