Approach 1:
Start from storey 1 and go up. keep dropping one of the eggs. As soon
at it breaks, return the storey you are in now. No. of drops in the
worst case: 99
Approach 2:
Split the building into 10 '10 storeyed' parts.
Start Dropping eggs at 10,20,30,...th storey.
If it breaks at say
The question can be restated as follows:
Given a graph, is it bipartite?. If yes, find the partition.
A graph is bipartite if and only if there is no odd cycle.
The following algo wl find the partition and if there is an odd cycle,
it wl report that it is not possible.
Level Decompose the
Try this:
http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor
On Jul 4, 5:15 pm, geek forgeek geekhori...@gmail.com wrote:
any1
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Radix sort can solve the problem in O(N) time.
Max. value of input is N^2
so in binary representation, we need d = 2(logN)+1 digits to represent
each number. ( It is O(logN) - thats the key)
Now group logN bits ( say r = logN )
The maximum value in each group is O( 2^r) This is the base in which
I will explain with an example:
3
a --- b
| |
| |
| 5 | 4
| |
c-d
1
lets say we want to find the shortest path from c to b,
denote sp(x,y) as the length of the shortest path from x to y
SP(c,b) = min( SP(c,a) + SP(a,b) , SP(c,d) +
Tell me the approach you have thought of.
On Jun 28, 8:39 am, Ashish Goel ashg...@gmail.com wrote:
Hi,
The implementation is simple using 2 stacks, however we also need to make
sure that if queue length is say x, we are able to enqueue x elements. As
per my understanding, i could think of