From c5633c2487f487cf65ae76287d0931ea032833dd Mon Sep 17 00:00:00 2001 From: Gabriel Donnan <47415809+gabedonnan@users.noreply.github.com> Date: Fri, 3 Nov 2023 21:37:13 +0000 Subject: [PATCH] Create build-an-array-with-stack-operations.py --- build-an-array-with-stack-operations.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 build-an-array-with-stack-operations.py diff --git a/build-an-array-with-stack-operations.py b/build-an-array-with-stack-operations.py new file mode 100644 index 0000000..be528a4 --- /dev/null +++ b/build-an-array-with-stack-operations.py @@ -0,0 +1,13 @@ +class Solution: + def buildArray(self, target: List[int], n: int) -> List[str]: + output = [] + cur = 1 + for item in target: + while cur < item: + output.append("Push") + output.append("Pop") + cur += 1 + + output.append("Push") + cur += 1 + return output