Created
March 27, 2022 02:43
-
-
Save ericness/865b9edf98085c986edd9132305f6e89 to your computer and use it in GitHub Desktop.
LeetCode 647 Brute force solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def countSubstrings(self, s: str) -> int: | |
"""Find number of palindromic strings in s | |
Args: | |
s (str): String to analyze | |
Returns: | |
int: Count of palindromes | |
""" | |
palindromes = 0 | |
for i in range(len(s)): | |
for j in range(i, len(s)): | |
if s[i:j] == s[j:i:-1]: | |
palindromes += 1 | |
return palindromes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment