Skip to content

Commit 45b1404

Browse files
add 1935 prod variant
1 parent 6eba473 commit 45b1404

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

contest/src/main/java/com/github/contest/strings/StringsProdVariant.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,21 @@ fun divideStringProdVariant(s: String, k: Int, fill: Char): Array<String> = when
7777
else -> s.chunked(k).toMutableList().apply {
7878
this[this.lastIndex] = this.last().padEnd(k, fill)
7979
}.toTypedArray()
80+
}
81+
82+
/**
83+
* 1935. Maximum Number of Words You Can Type
84+
* Prod Variant
85+
*/
86+
87+
fun canBeTypedWords(text: String, brokenLetters: String): Int {
88+
val words = text.split(" ")
89+
return if (brokenLetters.isEmpty()) words.size else {
90+
val set = brokenLetters.toSet()
91+
words.count {
92+
it.all { letter ->
93+
!set.contains(letter)
94+
}
95+
}
96+
}
8097
}

0 commit comments

Comments
 (0)