diff --git a/solutions/037.md b/solutions/037.md index d77e21d..2b2545a 100644 --- a/solutions/037.md +++ b/solutions/037.md @@ -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.