Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Advanced DP

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Advanced DP

Burst Balloons

advancedlayer A1 · Advanced DP5 tests

You are given nums, the numbers painted on a row of balloons. Bursting the balloon at index i earns you left * nums[i] * right coins, where left and right are the balloons immediately beside it at that moment. A missing neighbour (off the end of the row) counts as a balloon painted 1. After a burst the row closes up. Return the most coins you can collect by bursting all of them.

  • You choose the order freely
  • An empty row earns 0
  • Greedily bursting the cheapest (or the most expensive) balloon first is not optimal

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen