Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-016

Rotate 90 Degrees

Problem

Rotate a 2D image 90 degrees clockwise.

An H x W input produces a W x H output where output[i][j] equals image[H - 1 - j][i].

Test cases

case 1
in: [[[1,2,3],[4,5,6]]]
expected: [[4,1],[5,2],[6,3]]
case 2
in: [[[1,2],[3,4]]]
expected: [[3,1],[4,2]]
case 3
in: [[[7]]]
expected: [[7]]
case 4
in: [[[1,2],[3,4],[5,6]]]
expected: [[5,3,1],[6,4,2]]
Starter codePython
def rotate_90(image):
    # Your code here
    pass

4 test cases · run your code against them in the editor