Skip to content

Commit 0a45dc6

Browse files
committed
add 1299 kotlin solution
1 parent 52f5a5a commit 0a45dc6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
fun replaceElements(arr: IntArray): IntArray {
3+
val res = IntArray(arr.size)
4+
var max = -1
5+
6+
arr.reversed().forEachIndexed { i, value ->
7+
res[i] = max
8+
max = maxOf(max, value)
9+
}
10+
return res.reversed().toIntArray()
11+
}
12+
}

0 commit comments

Comments
 (0)