[LeetCode] 2390. Removing Stars From a String(Kotlin)

0

LeetCode

목록 보기
57/58
post-thumbnail
post-custom-banner

[LeetCode] 2390. Removing Stars From a String(Kotlin)

풀이

import java.util.Deque

class Solution {
    fun removeStars(s: String): String {
        val st = ArrayDeque<Char>()
        s.forEach{ ch ->
            if(ch == '*') st.removeLast()
            else st.addLast(ch)
        }
        return st.toList().joinToString(separator="")
    }
}
profile
Be able to be vulnerable, in search of truth

0개의 댓글