Skip to content

Commit

Permalink
Create build-an-array-with-stack-operations.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gabedonnan authored Nov 3, 2023
1 parent 2a51c20 commit c5633c2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions build-an-array-with-stack-operations.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c5633c2

Please sign in to comment.