# 1441. Build an Array With Stack Operations ###### tags: `Leetcode` `Easy` Link: https://leetcode.com/problems/build-an-array-with-stack-operations/ ## Code ```java= class Solution { public List<String> buildArray(int[] target, int n) { List<String> ans = new ArrayList<>(); int idx = 0; int num = 1; while(idx<target.length){ ans.add("Push"); if(target[idx]==num){ idx++; } else{ ans.add("Pop"); } num++; } return ans; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up