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

g1401_1500.s1408_string_matching_in_an_array.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.32
Show newest version
package g1401_1500.s1408_string_matching_in_an_array

// #Easy #String #String_Matching #2023_06_07_Time_194_ms_(77.78%)_Space_36.8_MB_(77.78%)

class Solution {
    fun stringMatching(words: Array): List {
        val set: MutableSet = HashSet()
        for (word in words) {
            for (s in words) {
                if (word != s && word.length < s.length && s.contains(word)) {
                    set.add(word)
                }
            }
        }
        return ArrayList(set)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy