LeetCode Entry

1935. Maximum Number of Words You Can Type

15.09.2025 easy 2025 kotlin rust

Count words with all letters

1935. Maximum Number of Words You Can Type easy blog post substack youtube

1.webp

Join me on Telegram

https://t.me/leetcode_daily_unstoppable/1113

Problem TLDR

Count words with all letters #easy

Intuition

No special algo here. Broken letters is up to 26, no hashset needed.

Approach

  • write a one-liner

Complexity

  • Time complexity: \(O(n)\)

  • Space complexity: \(O(n)\)

Code


// 14ms
    fun canBeTypedWords(txt: String, bl: String) =
        txt.split(" ").count { it.all { it !in bl}}


// 0ms
    pub fn can_be_typed_words(txt: String, bl: String) -> i32 {
        txt.split(" ").filter(|w| !w.chars().any(|c| bl.contains(c))).count() as _
    }