sethia
BAN USER
Comments (6)
Reputation 0
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.
0
of 0 vote
There can be a better solution.
If you get to store the list in a doubly linked list, then you can reverse it in O(1).
You might understand what I said if you have studied Linked List from Thomas H Cormen's book. There is a problem there for reversing a linked list in O(1). The solution can apply here as well.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
@vishu: I think that the complexity would be the worse of O(n logn) and O(n). Therefore the complexity of your solution is O(n logn). What do you think?
- sethia November 01, 2012