Booking.com Associate Developer Interview Question 2024 May | Backtracking | on-campus

Question · Posted Jun 2026

Question 1: 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: For n=3, there are exactly 5 valid combinations (Catalan number C3=5). At each step, we can add '(' if we still have open brackets remaining, or add ')' if the number of close brackets used is less than open brackets used so ...

The full answer & interview discussion are available to premium members.

Log in Create a free account