.::Kotlin::. StringBuilder as Stack
\nclass Solution {\n    fun backspaceCompare(s: String, t: String): Boolean =\n        reduce(s) == reduce(t)\n\n    fun reduce(str: String): String = buildStri
```\nclass Solution {\n    fun backspaceCompare(s: String, t: String): Boolean =\n        reduce(s) == reduce(t)\n\n    fun reduce(str: String): String = buildString {\n        for (char in str) {\n            if (char == \'#\') {\n                if (!isEmpty()) setLength(length - 1)\n            } else {\n                append(char)\n            }\n        }\n    }\n}\n```
['Kotlin']