1441. Build an Array With Stack Operations
https://leetcode.com/problems/build-an-array-with-stack-operations
Description
Given an array target
and an integer n
. In each iteration, you will read a number from list = {1,2,3..., n}
.
Build the target
array using the following operations:
Push: Read a new element from the beginning
list
, and push it in the array.Pop: delete the last element of the array.
If the target array is already built, stop reading more elements.
Return the operations to build the target array. You are guaranteed that the answer is unique.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= target.length <= 100
1 <= target[i] <= n
1 <= n <= 100
target
is strictly increasing.
ac
Previous1440. Evaluate Boolean ExpressionNext1442. Count Triplets That Can Form Two Arrays of Equal XOR
Last updated