# Maximize Score After N Operations: Walkthrough

Maximize Score After N Operations shows up often in coding rounds. Here is how I talk through it when the interviewer is watching.

## Key idea

2n numbers; n times pick two unused numbers x, y and add i * gcd(x, y) on operation i. The state space is a bitmask of unused numbers. DP on the mask: the operation index is determined by how many pairs are already taken. Try every unused pair, recurse, and keep the max.

## Steps to say out loud

1. Restate the input and the exact ask, and nail down constraints and overflow.
2. Name the pattern (binary search on the answer, monotonic stack or deque, interval / interval-DP, string hashing, graph traversal, or shortest paths) and why a nested scan or naive search fails.
3. Code it, then trace a short example plus one empty or already-solved edge case.

## Complexity

O(2^{2n} * n^2) with 2n <= 14.

## Common mistake

Using the numbers' values as the operation index instead of the count of remaining pairs, or computing gcd outside the pair loop incorrectly.

## Practice tip

Time yourself: two minutes to explain, ten to code, three to test edges. Disclosure: I work on Linkjob AI. I also keep a practice cheat sheet at real-time AI interview assistant for live interviews.