ans to store the stack operations.i to 0, representing the next number to be pushed from the stream.num in the target array:
a. While i is less than num:
i. Append 'Push' to ans.
ii. Increment i.
iii. If i is not equal to num, append 'Pop' to ans.
b. Append 'Push' to ans (for the current num).
i. Increment i.ans containing the sequence of operations.