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