flow
The if-else if-else chain can be reduced to two if-statements.
This is because the case where the absolute value of cur and prev are the same is just the other two cases combined.
As far as I know, you do need more variables, to make it possible. Therefor, this is just another choice, with its own drawbacks:
fun asteroidCollision(asteroids: IntArray): IntArray { val stack = asteroids.toMutableList() var index = stack.lastIndex while (index >= 1) { val curIndex = index val cur = stack[curIndex] val prevIndex = index-1 val prev = stack[prevIndex] if (prev.isRight() && cur.isLeft()) { if (abs(prev) >= abs(cur)){ stack.removeAt(curIndex) if (index-1==stack.lastIndex) index-- } if (abs(cur) <= abs(prev)){ stack.removeAt(prevIndex) index-- } } else index-- } return stack.toIntArray() }