0x0
BAN USER
Comments (4)
Reputation -5
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
-1
of 1 vote
The solution can be easily modified to be correct.
after detonating the first bomb, the circle is breaked up to a line;
after detonating every subsequent bomb, a line is breaked up into 2 lines.
Just need to handle the first bomb (loop through all bombs as the first bomb)
adds a factor of n in the complexity. But gonna be polynomial
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
From the amount of "new" statement you have, it is obvious that the statement "in constant space" in question cannot be achieved.
- 0x0 October 11, 2013Maybe it is only possible either to have time O(m+n) and space O(m+n), or time((m+n)log(m+n)), space O(1)