Sorry I forgot to take any pics, but the question is pretty simple:
def countStrings(s: str) -> int:
...
return countThe question states that:
array[0] = sex:
s = "abba"
array = ["abba", "bbaa", "baab", "aabb"]
result = 2 explanation: "abba" and "baab" have first and last char as the same
ex2:
s = "aaabbba"
array = ["aaabbba", "aabbbaa", "abbbaaa", "bbbaaaa", "bbaaaab", "baaaabb", "aaaabbb"]
result = 5explanation: "aaabbba", "aabbbaa", "abbbaaa", "bbaaaab", "baaaabb"
I forgot the constraints of how long the string could be but it was really long and basically a brute force of creating the strings wouldn't work b/c of TLE. So I'm guessing this is basically a math problem and you shouldn't create new strings, but I had no idea how to solve.
Any ideas??