Back to questionsDSA Visualizers: 388 Coding Questions Ninja Training visualizer Learn Ninja Training with a step-by-step Dynamic Programming visualizer, JavaScript source code and a worked example. Practice one dimensional dp.
INTERACTIVE EXECUTION STUDIOLEARN BY DOING Predict. Execute. Understand. Follow the source code, inspect live state changes, and predict the next operation before revealing it.
1 / 4 Execution step
Prediction modePanel width Reference example · JavaScript
Inspect reference input [
[
10,
40,
70
],
[
20,
50,
80
],
[
30,
60,
90
]
] Code Visuals
JavaScript reference implementation · highlighted trace statement
1 const solve = (a,s)=>{
2 let d=[0 ,0 ,0 ];
3 for (let r of a){
4 d=r.map((v,j)=>v+Math.max(...d.filter((_,i)=>i!==j)));
5 s("Choose activity different from previous day",{
6 Points:a,DP:d
7 })
8 }
9 return Math.max(...d)
10 };
Execution canvas Active ChangedSTEP 1 Choose activity different from previous day Inspect the highlighted code and the state below. Click individual cells or nodes to see their values.
Worked example and algorithm walkthrough Topic: Dynamic Programming · One dimensional DP
Follow the computed execution on the reference input. Advance one step at a time, inspect the changing values and compare your prediction with the final output.
Example input [
[
10,
40,
70
],
[
20,
50,
80
],
[
30,
60,
90
]
] Execution steps Choose activity different from previous day Computed output 210 JavaScript reference implementation const solve = (a,s)=>{
let d=[0,0,0];
for(let r of a){
d=r.map((v,j)=>v+Math.max(...d.filter((_,i)=>i!==j)));
s("Choose activity different from previous day",{
Points:a,DP:d
})
}
return Math.max(...d)
};Continue learning Practice related DSA questions in the same topic.