Sunday, September 19, 2010

Reverse linked list using one pointer

How to reverse linked list using single extra pointer?.
We should not use recursion.

Maximum sub matrix in a given matrix

How to find maximum sum of sub matrix in a given matrix of numbers?.

Given a Chess board and 3 coins, how many number of ways you can place them so that all the coins are in the same diagonal?

Given a Chess board and 3 coins, how many number of ways you can place them so that all the coins are in the same diagonal?

Count the number of numbers up to n which are both square and cube.

Count the number of numbers up to n which are both square and cube.
e.g., for 1 < n < 1000 answer is 2 (64, 729)

Maximum sub array sum in array

You have an array of N elements and you have to find the subarray of out of this array whose sum is maximum. The condition is no two element that you chose in your subarray should be adjacent to each other in the original array. How will you do this polynomial time??