Problem statement

https://binarysearch.com/problems/Unique-Ab-Strings/

Solution

Answer is just 2 to the power of number of a we have.

Complexity

It is O(n) if we assume that answer fits int32

Code

class Solution:
    def solve(self, s):
        return 1<<s.count("a")