Kotlin solution
Code\n\nclass Solution {\n    fun minRemoveToMakeValid(s: String) = buildString {\n        val indexes = mutableListOf<Int>()\n        s.forEach {\n            
# Code\n```\nclass Solution {\n    fun minRemoveToMakeValid(s: String) = buildString {\n        val indexes = mutableListOf<Int>()\n        s.forEach {\n            when (it) {\n                \'(\' -> indexes.add(length)\n                \')\' -> if (!indexes.isEmpty()) indexes.removeLast()\n                       else return@forEach\n            }\n            append(it)\n        }\n        indexes.reversed().forEach {\n            deleteAt(it)\n        }\n    }\n}\n```\n\nLet me know if you have any suggestions. Thanks!
['Kotlin']