![JAR search and dependency download from the Maven repository](/logo.png)
g2801_2900.s2810_faulty_keyboard.Solution.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-kotlin Show documentation
Show all versions of leetcode-in-kotlin Show documentation
Kotlin-based LeetCode algorithm problem solutions, regularly updated
package g2801_2900.s2810_faulty_keyboard
// #Easy #String #Simulation #2023_12_06_Time_196_ms_(91.67%)_Space_36.9_MB_(91.67%)
class Solution {
fun finalString(s: String): String {
val stringBuilder = StringBuilder()
for (ch in s.toCharArray()) {
if (ch == 'i') {
stringBuilder.reverse()
continue
}
stringBuilder.append(ch)
}
return stringBuilder.toString()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy