![JAR search and dependency download from the Maven repository](/logo.png)
g1601_1700.s1668_maximum_repeating_substring.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 g1601_1700.s1668_maximum_repeating_substring
// #Easy #String #String_Matching #2023_06_15_Time_170_ms_(100.00%)_Space_35.8_MB_(50.00%)
class Solution {
fun maxRepeating(sequence: String, word: String): Int {
var k = 0
val repeat = StringBuilder(word)
while (sequence.contains(repeat)) {
k++
repeat.append(word)
}
return k
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy