Amazon Interview Question

K closest element Generate all valid parenthesis