Sign In
You are coding as a Guest. Sign in with your RoleNest account to permanently track your streak, earn XP, and climb the Campus Leaderboard!
Sign In with RoleNest
🔥Generate Parentheses: Backtracking TreeMedium
DAILY PROBLEM OF THE DAY+50 XP • Daily Streak

Solve today's challenge or tackle one of the 3 Super Hard challenges for +150 XP.

MediumStack•Acceptance: 74.8%

Generate Parentheses: Backtracking Tree

Targeted in FAANG & Tech OA:GoogleAmazonMicrosoftSwiggyUber
Real-World Engineering Context
AST parser generation, mathematical formula validation, and compiler grammar tree construction.
Given `n` pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Sample Test Cases

Input: [3]
Expected: ["((()))","(()())","(())()","()(())","()()()"]
Input: [1]
Expected: ["()"]

Constraints

  • 1 <= n <= 8
Recruiter Fast-Track ReferralVerified Candidate
Direct pipeline to Google, Amazon, Microsoft, Swiggy, & Uber recruiters
DevScore: 750/1000

Top DevScore profiles bypass resume screening filters. Every verified problem solve writes authentic proof-of-work to your profile and dispatches you directly into employer inboxes on RoleNest.