Maximize Coins Earned by Popping Reaction Bubbles in the Best Order

Last updated: November 29, 2026

Quick Overview

A row of reaction bubbles each has a value. Popping bubble i earns left * value[i] * right, where left and right are its current neighbors (treated as 1 past the ends). Return the maximum total coins from popping every bubble.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


A row of reaction bubbles each has a value. Popping bubble i earns left * value[i] * right, where left and right are its current neighbors (treated as 1 past the ends). Return the maximum total coins from popping every bubble.

A classic Meta onsite interval DP problem that separates candidates who memorize from those who can find the right subproblem. The interviewer is looking for the insight to choose the last bubble popped in an interval, which makes the two sides independent.

What the Interviewer Expects
  • Explain why choosing the first pop leads to dependent subproblems
  • Pad the array with 1s at both ends
  • Define dp over open intervals and pick the last bubble popped
  • Fill intervals in increasing length order
  • State O(n^3) time and O(n^2) space
Key Topics to Cover
Interval dynamic programming
Last-action decomposition
Memoization
Burst balloons
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you reconstruct the popping order?
  • Can you write it top-down with memoization instead?
  • What if popping a bubble scores left + right instead of a product?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input is a list vals of non-negative integers, length 0 to about 300. When a bubble is popped its neighbors become adjacent. Out-of-range neighbors count as 1. Return the maximum total coins....

High-Level Design

Guessing which bubble to pop first fails, because the neighbors of the remaining bubbles keep changing. Instead, pad vals to [1] + vals + [1] and let dp[l][r] be the best coins from popping ever...


Submit Your Answer
Markdown supported