FastPrepGenerate Parentheses
Problems/Generate Parentheses

Generate Parentheses

Expedia logoExpedia● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report's example for three pairs is kept. We chose lexicographic order, what to return for zero pairs, and the limits. Our version is about 98% the same as the reported question.

Return every balanced parentheses string containing exactly n opening and n closing parentheses.

Each prefix must contain at least as many opening as closing parentheses. Return the distinct strings in lexicographic order. For n = 0, return an array containing one empty string.

Function

generateParenthesis(n: int) → List<String>

Examples

Example 1

n = 3return = ["((()))","(()())","(())()","()(())","()()()"]

These are all 5 balanced strings using three pairs, in lexicographic order.

Example 2

n = 1return = ["()"]

There is one balanced string with one pair: ().

Constraints

  • 0 <= n <= 8.

More Expedia Online Assessment questions

  • Balanced NumbersOA · Seen Aug 2026
  • REST API: Discounted PriceOA · Seen Aug 2026
  • Maximum Team SizeOA · Seen Mar 2026
  • Per-Domain Request LimiterOA · Seen Oct 2025
  • Count Equal-Frequency SubsequencesOA · Seen Mar 2025
  • Count Increasing Stock PeriodsOA · Seen Mar 2025
  • Get Minimum StepsOA · Seen Oct 2024
  • Rank Songs by PopularityOA · Seen Oct 2024
  • Calculate the SumOA · Seen Oct 2024
  • Get Maximum EfficiencyOA · Seen Oct 2024

Similar questions at other companies

  • Next Number with Disjoint DigitsElevenLabs · OAElevenLabs interview questions
  • String Permutations in Custom Character OrderWex · OA · PHONE SCREEN
  • Generate ParenthesesThe Walt Disney Company · OAThe Walt Disney Company interview questions
  • Reverse and AppendUber · OAUber interview questions
  • Generate ParenthesesAtlassian · OAAtlassian interview questions
  • Equal-Sum Digit PartitionsAlchemy · OA
  • Maximum Number after K SwapsIntuit · OAIntuit interview questions
  • Generate Balanced ParenthesesInMobi · OAInMobi interview questions
  • Work ScheduleSnowflake · OASnowflake interview questions
  • Work Schedules (for MTS2)Nutanix · OANutanix interview questions

Interview reports that mention this question

  • Expedia New Grad SDE Earlier Loops: 5 Experiences (Part 2 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public List<String> generateParenthesis(int n) {
      // Write your code here.
    }

}
Checking account…