- minStack always stores the current minimum.
- push to minStack only if it’s a new minimum.
- pop from minStack only if ive removed the minimum.
-
Time complexity:O(1)
-
Space complexity:O(N)
immediately i saw the question my head went to a buble sort
Time complexity:O(N)
Space complexity:O(1)
Time complexity: O(N^2)
Space complexity: O(N)
Time complexity:O(Nlogn)
Space complexity: O(N)
Time complexity:O(N)
Space complexity:O(N)