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

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"

Thursday, December 20, 2012

Find the minimal required number of white balls to achieve below criteria

You are given C containers, B black balls and an unlimited number of white balls. You want to distribute balls between the containers in a way that every container contains at least one ball and the probability of selecting a white ball is greater or equal to P percent. The selection is done by randomly picking a container followed by randomly picking a ball from it.

Find the color of the k-th ball (1-index based) that will be destroyed.

Bob is playing with his ball destroyer robot. Initially, Bob has r red balls, g green balls and b blue balls. The robot will repeat the following 3-step program until there are no balls left:

  • If there is at least one red ball available, destroy one red ball.
  • If there is at least one green ball available, destroy one green ball.
  • If there is at least one blue ball available, destroy one blue ball.
You are given the longs r, g and b. You are also given a long k. Find the color of the k-th ball (1-index based) that will be destroyed.
  • If the color of the k-th ball to be destroyed is red, return "RED" (quotes for clarity, returned values are case-sensitive).
  • If the color is green, return "GREEN".
  • If the color is blue, return "BLUE".


Source : Commented by a user named bob , later i found property of TopCoder , so i have am just sharing it to learning purpose , TopCoder Inc. holds all right on the problem statement .