DEV Community

Siddhesh Bhupendra Kuakde
Siddhesh Bhupendra Kuakde

Posted on

1935. Maximum Number of Words You Can Type |

Intuition

Given string some char broken they cant be used to make that word. return the miniumum number of words that we can form with this.

Approach

just check and reduce the count if the chars are found

Complexity

  • Time complexity:
  • O arr size and O borken letter size

  • Space complexity:

  • On for array

Code

```cpp []
class Solution {
public:
int canBeTypedWords(string text, string brokenLetters) {

    // Hello world ad  
    stringstream ss(text);
    vector<string> arr; 
    string word;    
    while(ss >> word){
        arr.push_back(word);
    }
    int ans = arr.size(); 
    for(string  s: arr){

        for(int i=0; i<brokenLetters.size(); i++){
            if(s.contains(brokenLetters[i])){ 
               --ans; break;
            }
        }

    }
    return ans; 
}
Enter fullscreen mode Exit fullscreen mode

};


Enter fullscreen mode Exit fullscreen mode

Top comments (0)