diff --git a/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README.md b/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README.md index a7320c165279a..bffb393bccb8e 100644 --- a/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README.md +++ b/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README.md @@ -99,6 +99,24 @@ function countGoodSubstrings(s: string): number { } ``` +### **PHP** + +```php +class Solution { + /** + * @param String $s + * @return Integer + */ + function countGoodSubstrings($s) { + $cnt = 0; + for ($i = 0; $i < strlen($s) - 2; $i++) { + if ($s[$i] != $s[$i + 1] && $s[$i] != $s[$i + 2] && $s[$i + 1] != $s[$i + 2]) $cnt++; + } + return $cnt++; + } +} +``` + ### **...** ``` diff --git a/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README_EN.md b/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README_EN.md index cc5a5586cd1ee..4a4aa3b53c5d1 100644 --- a/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README_EN.md +++ b/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README_EN.md @@ -89,6 +89,24 @@ function countGoodSubstrings(s: string): number { } ``` +### **PHP** + +```php +class Solution { + /** + * @param String $s + * @return Integer + */ + function countGoodSubstrings($s) { + $cnt = 0; + for ($i = 0; $i < strlen($s) - 2; $i++) { + if ($s[$i] != $s[$i + 1] && $s[$i] != $s[$i + 2] && $s[$i + 1] != $s[$i + 2]) $cnt++; + } + return $cnt++; + } +} +``` + ### **...** ``` diff --git a/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/Solution.php b/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/Solution.php new file mode 100644 index 0000000000000..02d8e4c54dc96 --- /dev/null +++ b/solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/Solution.php @@ -0,0 +1,13 @@ +class Solution { + /** + * @param String $s + * @return Integer + */ + function countGoodSubstrings($s) { + $cnt = 0; + for ($i = 0; $i < strlen($s) - 2; $i++) { + if ($s[$i] != $s[$i + 1] && $s[$i] != $s[$i + 2] && $s[$i + 1] != $s[$i + 2]) $cnt++; + } + return $cnt++; + } +} \ No newline at end of file