Brace Expansion II

Solution Code

Time Complexity

O(n * M)

Space Complexity

O(n * M)