Skip to content

Commit 0ea73c2

Browse files
committed
Time: 172 ms (50%), Space: 35.5 MB (100%) - LeetHub
1 parent 8af7a43 commit 0ea73c2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
fun buildArray(target: IntArray, n: Int): List<String> {
3+
val result = mutableListOf<String>()
4+
var streamPeak = 0
5+
6+
for (number in target) {
7+
repeat(number - streamPeak - 1) {
8+
result.add("Push")
9+
result.add("Pop")
10+
}
11+
result.add("Push")
12+
streamPeak = number
13+
}
14+
15+
return result
16+
}
17+
}

0 commit comments

Comments
 (0)