Build an Array With Stack Operations LeetCode solution in Python
1class Solution:2def buildArray(self, target: List[int], n: int) -> List[str]:3temp = []4result = []5x = target[-1]6for i in range(1, x + 1):7temp.append(i)8for i in range(len(temp)):9if temp[i] in target:10result.append("Push")11elif temp[i] not in target:12result.append("Push")13result.append("Pop")14return result