We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Since this was supposed to be a stack problem I was also annoyed by other solutions using arrays. So here is my Python solution using the python stack operations pop, append and the equiv of peek is lst[-1]. Notice I also reversed the original data since Python pop is O(n) if you pop or delete the first element.
Game of Two Stacks
You are viewing a single comment's thread. Return to all comments →
Since this was supposed to be a stack problem I was also annoyed by other solutions using arrays. So here is my Python solution using the python stack operations pop, append and the equiv of peek is lst[-1]. Notice I also reversed the original data since Python pop is O(n) if you pop or delete the first element.