Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions solutions/037.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,28 @@ class Solution:
return count
```

### O(nm) solution using regular expressions

We will check every word that inside has any character that not allowed

#### PHP
class Solution {

/**
* @param String $allowed
* @param String[] $words
* @return Integer
*/
function countConsistentStrings($allowed, $words) {
$result = 0;
foreach($words as $word)
{
if(!preg_match('/[^' . $allowed . ']/', $word)){
$result++;
}
}
return $result;
}
}

***NB***: If you want to get community points please suggest solutions in other languages as merge requests.