Monday, April 8, 2013
Given a root of a tree, and an integer k. Print all the nodes which are at k distance from given elment
Tuesday, March 19, 2013
How would you design a logging system for something like Google , you should be able to query for the number of times a URL was opened within two time frames.
i/p : start_time , end_time , URL1
o/p : number of times URL1 was opened between start and end time.
Some specs : Database is not an optimal solution A URL might have been opened multiple times for given time stamp. A URL might have been opened a large number of times within two time stamps. start_time and end_time can be a month apart. time could be granular to a second.
Thursday, March 14, 2013
Assume you daily prices of a stock 3 7 4 10 11 8 5 4 8 . You can only buy 1 share or sell 1 share a day, but you can only sell if you own the stock. You can't hold more than 1 share. write me an algo that finds me the strategy that has the highest pay off. Don't want the generate all possible strategies and compare.
Tuesday, March 12, 2013
We're playing a game. Cards numbered from 1-10 are placed in a hat. whatever card is drawn is the paid out amount. how much should i charge you to play this game? If you can redraw by placing the first card back into the hat, what is the new price?
Monday, March 4, 2013
You have N guards in a line each with a demand of coins.You can skip paying a guard only if his demand is lesser than what you have totally paid before reaching him.Find the least number of coins you spend to cross all guards
Monday, February 25, 2013
Implement LookAndSay function. For example, first, let user input a number, say 1. Then, the function will generate the next 10 numbers which satisfy this condition: 1, 11,21,1211,111221,312211... explanation: first number 1, second number is one 1, so 11. Third number is two 1(previous number), so 21. next number one 2 one 1, so 1211 and so on...
Source : Heard from Junior , EPIC visit to BIT Mesra
'K' number of char arrays of different length are given, find Cartesian product of them in optimal way & give complexity.
Source : commented by user yen
Given n, output the numbers from 0 to 2^n-1 (inclusive) in n-bit binary form, in such an order that adjacent numbers in the list differ by exactly 1 bit.
Source : Heard from Rahul, CSE, BITS ,2K10
Wednesday, January 23, 2013
Monday, January 21, 2013
Since i dont want to stop hacking , i decided to post simple problem to start off the new year , Happy hacking , give its try !!!
PS: 1 billion is big no. its equal to no. of user facebook have ;)