Leetcode | Letter Tile Possibilities

I came across Letter Tile Possibilities in Leetcode weekly contest 140.

I have solved this problem and got accepted.

This is my solution can anyone help me deriving complexity of my code.

Is there are more optimal way to solve this problem?