Find Lowest Common Ancestor of 2 nodes
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
Just another WordPress weblog
Archive for the ‘Yahoo’ Category.
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
Write a program to reverse a linked list
1. With recursion
2. Without Recursion
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.
Write an algorithm to shuffle an array of 52 integers so that each number has equal probability to be in any of the 52 positions.