@harit

Maintaining only one data member, minimum will not suffice. As we may
call min() any number of time and every time it should return the
minimum of all data members.

@sharad
Thanks for direction.
In your implementation, stack.top() and stack.pop() are going to
return same value.
So min() and pop() will return the same value that is not correct.
Lets say we have to push 2 items in stack , 2 & 5 respectively.
It will be maintained as,
2
2
5
5
Now min() will return 2 but pop() will also return 2. While pop() must
return 5.
I guess, little variation of your code will work fine. I will work it
out.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to