diff --git a/README.md b/README.md index 7edfb54..01bb04c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # snippets -Favorite code snippets \ No newline at end of file +Favorite code snippets + +All code follows the MIT license \ No newline at end of file diff --git a/stack_removal_order_checker.py b/stack_removal_order_checker.py new file mode 100644 index 0000000..4d24b20 --- /dev/null +++ b/stack_removal_order_checker.py @@ -0,0 +1,9 @@ +def check(in_list: list, out_list: list) -> bool: + stack = [] + i = 0 + for num in in_list: + stack.append(num) + while stack and stack[-1] == out_list[i]: + stack.pop() + i += 1 + return not stack \ No newline at end of file