Skip to content

Array

How to rotate a 2D array by 90 degrees right or left

Rotate right

  1. Transpose
  2. Reverse each row

rotate left

  1. reverse each row
  2. transpose

???? Why does this work?


Last update: 2023-04-24