Tuesday, January 24, 2012

Euler Problem: Pandigital number

Multiplying 9 by 1, 2, 3, 4, and 5, gives the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5).

What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n) where n >1?

Its fun to solve the problem without the use of code :)

Saturday, January 21, 2012

[Amazon Online Test] Find the nodes at k distance.

Given a tree with the root and a particular node, find the nodes which are atmost at a distance of k from the particular node and print them in sorted order.


 Approach:

Lets say the given tree is


And the given node is of the value 50, and distance k = 3
Then the desired result is 5, 30, 50, 70, 90