AndurilMachine Learning Engineer · Technical ScreenCodemia practiceImplement Stack with O(1) space
Implement a stack data structure that supports push, pop, and top operations, all while using O(1) space complexity. Your implementation should allow for the following operations: `push(value)`, which adds an element to the top of the stack; `pop()`, which removes the top element and returns it; and `top()`, which returns the top element without removing it. Ensure that your stack can handle a sequence of these operations efficiently.
Medium
Coding & Algorithms