[LeetCode] 344. Reverse String(Kotlin)

0

LeetCode

목록 보기
23/58
post-thumbnail

[LeetCode] 344. Reverse String(Kotlin)

풀이

class Solution {
    fun reverseString(s: CharArray): Unit {
        val n = s.size
        var tmp: Char = ' '
        for(i in 0 until (n/2)){
            tmp = s[i]
            s[i] = s[n-i-1]
            s[n-i-1] = tmp
        }
    }
}
profile
Be able to be vulnerable, in search of truth

0개의 댓글