Problem Title Here

story-driven

Approach 1 / Approach 2

Describe the problem here. Keep it concise but precise enough that someone arriving fresh can understand what they're watching without opening LeetCode. You can reference code variables inline like nums[l..r] and explain the goal.

Medium • Dynamic Programming
TraceVisualizeLearn

The idea

The algorithm should feel like a sequence of small, readable moments.

overview
init
process
select
done

Current phase

init

Progress

1/8

Best result

0

Input array

Touch-friendly array viewport with range highlighting.

visual

Input Array

Processing Selected
0
1
1
3
2
2

Your Custom Panel

Storyboard
Replace this with your diagram (tree / DP table / graph / bars…)

Selected trail

A compact memory of the best states so far.

trace
None yet
Result:0

Step log

The algorithm, told as a sequence of moments.

journal
Initialize the optimized flow: move once, keep only what matters.

Code

Keep the implementation aligned with the story above.

source
optimized.cpp
1// Paste / write your optimized solution here
2void solve(vector<int>& nums, int k) {
3 // ...
4}