Twitter OA Question 2024 August | Backtracking | on-campus
Question · Posted Jun 2026
Question: Generate Parentheses Problem Statement Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Constraints 1 <= n <= 8 Examples Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Explanation 1: There are 5 unique ways to arrange 3 pairs of open and close brackets such that they are well-formed (no closing bracket precedes its matching open bracket). Example 2: Input: n = 1 Output: ["()"] Explanation 2: Only one pair of parentheses can ...
The full answer & interview discussion are available to premium members.
Log in Create a free account