Interview Questions/Coding/Max Score Token Burst

Max Score Token Burst

Preview mode. Log in to edit, run, submit, and save progress.

Hard

Max Score Token Burst

You have a row of numbered tokens. When you burst token i, you earn left * tokens[i] * right, where left and right are the nearest remaining token values beside it. If no token exists on one side, use 1 for that side. Return the maximum score possible after bursting every token.

Examples

Example 1
Input:
tokens = [3,1,5,8]
Output:
167

Approach hint

Add virtual 1 values at both ends.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp