Reverse the words in a sentence
Write a program to reverse the words in a string.String is represented as an array.
Input: hello my world
Expected Output: world my hello
Just another WordPress weblog
Archive for November 2009
Write a program to reverse the words in a string.String is represented as an array.
Input: hello my world
Expected Output: world my hello
Given a linked list, find out whether it is a palindrome or not
Given an MXN Matrix consisting of only elements 0’s or 1’s.
Find
1. Largest square matrix with 1’s
2. Largest rectagle with 1’s
3. Largest Square with borders made of 1’s
4. Largest Rectangle with borders made of 1’s
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
How do you find out intersection between two arrays
Case 1: One array huge compared to the other array
Case 2: One array sorted
Case 3: Both arrays sorted
Case 4: Unsorted and of equal length
Given a sorted array rotated n times. Find the number of right side rotations performed on the array.
Example:
input: 678912345
expected output: 4 (rotating 123456789 4 times we will get the input)
Given a document and a query of K words, how do u find the smallest window that covers all the words at least once in that document?
Given a String, find out all the valid dictionary words contained in the string.