<Whiteboard Questions> Q: Implement a stack or a queue (It can be done using an array or a linked list).
Anonimo
A: I implemented a stack using a linked list including two classes (Stack class and Node class) and three methods (push(value), pop(), and peek()) and made sure to handle edge cases (ex. handling cases where there's no node, one node, and more than one node; saving the old last node before deleting it so that you can return the node at the end of the function, and setting the new last node as this.top (equivalent to this.tail). I explained each method by drawing a diagram of a stack and a linked list with nodes and also adding comments above each function.