Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Matrix problems

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Matrix problems

Rotate Image

intermediatelayer I12 · Matrix problems5 tests

Given an n × n matrix, rotate it 90° clockwise, in place.

  • You must modify the matrix you were given — allocating a second matrix and returning it does not count
  • The return value is ignored; the caller reads the matrix it passed in
  • After the rotation, the first column read bottom-to-top becomes the first row
  • A 1×1 matrix is unchanged

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen