Back to questionsDSA Visualizers: 388 Coding Questions Rotate Image visualizer Learn Rotate Image with a step-by-step Arrays visualizer, JavaScript source code and a worked example. Practice optimization and matrix.
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 / 7 Execution step
Prediction modePanel width Reference example · JavaScript
Inspect reference input [
[
1,
2,
3
],
[
4,
5,
6
],
[
7,
8,
9
]
] Code Visuals
JavaScript reference implementation · highlighted trace statement
1 const solve = (m,s)=>{
2 for (let i=0 ;
3 i<m.length;
4 i++)for (let j=i+1 ;
5 j<m.length;
6 j++){
7 [m[i][j],m[j][i]]=[m[j][i],m[i][j]];
8 s("Transpose cells "+i+","+j,{
9 Matrix:m
10 })
11 }
12 for (let i=0 ;
13 i<m.length;
14 i++){
15 m[i].reverse();
16 s("Reverse row "+i,{
17 Matrix:m
18 })
19 }
20 return m
21 };
Execution canvas Active ChangedSTEP 1 Transpose cells 0,1 Inspect the highlighted code and the state below. Click individual cells or nodes to see their values.
Worked example and algorithm walkthrough Topic: Arrays · Optimization and matrix
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 [
[
1,
2,
3
],
[
4,
5,
6
],
[
7,
8,
9
]
] Execution steps Transpose cells 0,1 Transpose cells 0,2 Transpose cells 1,2 Reverse row 0 Reverse row 1 Reverse row 2 Computed output [
[
7,
4,
1
],
[
8,
5,
2
],
[
9,
6,
3
]
] JavaScript reference implementation const solve = (m,s)=>{
for(let i=0;
i<m.length;
i++)for(let j=i+1;
j<m.length;
j++){
[m[i][j],m[j][i]]=[m[j][i],m[i][j]];
s("Transpose cells "+i+","+j,{
Matrix:m
})
}
for(let i=0;
i<m.length;
i++){
m[i].reverse();
s("Reverse row "+i,{
Matrix:m
})
}
return m
};Continue learning Practice related DSA questions in the same topic.