All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g2701_2800.s2716_minimize_string_length.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.30
Show newest version
package g2701_2800.s2716_minimize_string_length

// #Easy #String #Hash_Table #2023_08_01_Time_204_ms_(97.62%)_Space_37.6_MB_(79.76%)

class Solution {
    fun minimizedStringLength(s: String): Int {
        val charMap = HashMap()
        for (i in s.indices) {
            val currentCount = charMap.getOrDefault(s[i], 0)
            charMap.put(s[i], currentCount + 1)
        }
        return charMap.size
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy