Build Array With Stack Ops

Given an integer array target and integer n, generate a list of operations to build the array using numbers from 1 to n. Two operations are available:

  • "Push": pushes the next number to the stack
  • "Pop": pops the top element from the stack

Return the list of operations to build the target array.

Every number from 1 up to the largest value in target is pushed exactly once. When a pushed number is not in target, it is popped right after being pushed. Stop as soon as the largest target value has been pushed: numbers greater than it are never processed and produce no operations.

Examples
Input: [[1,3],3]
Output: ["Push","Push","Pop","Push"]
Hints

Build Array With Stack Ops

Given an integer array `target` and integer `n`, generate a list of operations to build the array using numbers from 1 to n. Two operations are available: