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 your daily prices of a stock are 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 an algo that finds the strategy that has the highest pay off. Don't generate the all possible strategies and compare.


Monday, January 21, 2013

Find the sum of all the multiples of 3 or 5 below 1 billion.

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 ;)

Monday, December 24, 2012

Count maximum number of "connected 1" in given matrix

you have a matrix of N x N filled with 1 or 0. you can move only 1 step either right or 1 step down. you need to count maximum number of "connected 1" in given matrix. for example
0 0 1 1
1 1 1 0
1 0 1 0
0 1 0 1

[Start from top left] maximum no. of 1 is 4
[1,0][1,1][1,2][2,2]


Source -: Commented by a user "rakesh"