You are browsing the archive for 2010 April.

Finding prime numbers

April 23, 2010 in Uncategorized

Output all prime numbers up to a specified integer n.

Read the rest of this entry →

Maximum Height (Depth) of a Binary Tree

April 21, 2010 in binary tree

Given a binary tree, find its maximum height.

Read the rest of this entry →

Binary Search Tree In-Order Traversal Iterative Solution

April 20, 2010 in Uncategorized

Given a binary search tree, print the elements in-order iteratively without using recursion.

Read the rest of this entry →

Multiplication of numbers

April 16, 2010 in dynamic programming

There is an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. Solve it without division operator and in O(n). Read the rest of this entry →

Hacking a Google interview (From MIT)

April 14, 2010 in Uncategorized

Google interview is so popular that even MIT dedicates a course to it!

» Hacking a Google Interview Course Website Read the rest of this entry →

Rotating an array in place

April 13, 2010 in Uncategorized

Rotate a one-dimensional array of n elements to the right by k steps.
For instance, with n=7 and k=3, the array {a, b, c, d, e, f, g} is rotated to {e, f, g, a, b, c, d}.

Read the rest of this entry →

Searching an Element in a Rotated Sorted Array

April 13, 2010 in Uncategorized

Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). How do you find an element in the rotated array efficiently? You may assume no duplicate exists in the array.

Read the rest of this entry →

Finding all unique triplets that sums to zero

April 12, 2010 in Uncategorized

Given a set S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the set which gives the sum of zero. Read the rest of this entry →

How to determine if a point is inside a rectangle?

April 12, 2010 in Uncategorized

Given a 2D point and a rectangle, determine if the point is inside the rectangle.

Read the rest of this entry →

Reversing linked list iteratively and recursively

April 12, 2010 in Uncategorized

Implement the reversal of a singly linked list iteratively and recursively.

Read the rest of this entry →