Back Clear
# Your Problem: # We'll say that a "pair" in a string is two instances of a char separated by # a char. So "AxA" the A's make a pair. Pair's can overlap, so "AxAxA" # contains 3 pairs -- 2 for A and 1 for x. Recursively compute the number of # pairs in the given string. # # # countPairs("axa") → 1 # countPairs("axax") → 2 # countPairs("axbx") → 1 # # Credit for this problem goes to Nick Parlante from CodingBat.com # Do not modify anything outside of the function or the function itself. # CODE START def getCountPairs(str:str) -> int: # CODE END # Press Ctrl+E (Command+E on mac) to test your code