← 返回 bytedance 的题目列表Enumerate All Valid Strings After Replacing * in Parentheses
类型:online_judge
Given a string s containing only '(', ')', and '*'. Each '*' can be replaced by '(', ')', or the empty string "".
Output all valid parentheses strings (with no '*') obtainable from s. Deduplicate results and print them in lexicographical order.
Input: one line string s
Output:
First line: integer k (#results)
Next k lines: each a valid parentheses string
Constraints (to keep enumeration feasible): 1 <= len(s) <= 20
Example Input: (*) Output (lex order):
2
()
(())
Example
Input
(*)
Output
2
()
(())