Generate Parentheses
Trung bình⚡ Thuật toán 5000ms 256MB
Generate Parentheses
Đề bài
Tạo tất cả n cặp ngoặc hợp lệ.
Ví dụ
Ví dụ 1:
Input: 3
Output: ["((()))","(()())","(())()","()(())","()()()"]
Ví dụ 2:
Input: 1
Output: ["()"]
Ràng buộc
- Dữ liệu đầu vào luôn hợp lệ
Case 1
Input = 3
Output = ["((()))","(()())","(())()","()(())","()()()"]
Case 2
Input = 1
Output = ["()"]