301. Remove Invalid Parentheses

use unmatched count to find the final ans

if unmatched count == 0 means can be add to result (and i == s.size()...currStr == maxLen

T: O(2^n) in worst

S: O(n), stack depth

BFS

T(n) = n x C(n, n) + (n-1) x C(n, n-1) + ... + 1 x C(n, 1) = n x 2^(n-1).

T: O(n*2^(n-1))

S: O(n)

11/30

Last updated

Was this helpful?