Untitled

요약

체크해야 되는것

fun isComplete(sb: StringBuilder) : Boolean{
    val buckets = mapOf(']' to '[', '}' to '{', ')' to '(')
    val first = sb.first()
    if(buckets.keys.contains(first)) return false

    val stack: Stack<Char> = Stack()
    sb.forEach {
        when(it) {
            '[', '{', '(' -> stack.push(it)
            ']', '}', ')' -> {
                if(stack.isEmpty()) return@forEach
                val closed = stack.pop()
                if(closed != buckets[it]) return false
            }
        }
    }

    return stack.isEmpty()
}