for n no’s we are using push n times so how its worjing in O(1)
Get min by stack
hello @deepakjumani09
yeah overall complexity will be O(n) .
here O(1) time complexity means to get minimum element in stack ur algorithm is taking constant time.
for n no’s we are using push n times so how its worjing in O(1)
hello @deepakjumani09
yeah overall complexity will be O(n) .
here O(1) time complexity means to get minimum element in stack ur algorithm is taking constant time.