본문 바로가기

알고리즘

릿코드 977. Squares of a Sorted Array 코틀린

그냥 제곱하고 정렬쳐서 리턴

정답

class Solution {
    fun sortedSquares(nums: IntArray): IntArray {
        return nums.map { it * it }.sorted().toIntArray()
    }
}