Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Algorithm - Interview Questions and Answers for 'Complexity' - 2 question(s) found - Order By Newest | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
| ||||
Ans. Create one extra field called MAX O(1) when you an element to the stack check these two condition 1. Stack is empty, then MAX = element 2. Stack is not empty then check if the element is greater than MAX then MAX = element when getMax fuction is called, then return MAX | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||