FastPrepRotate a Rectangular Image Clockwise

Rotate a Rectangular Image Clockwise

Luma AI logoLuma AI● EasyFULLTIMEOA
Learn

Problem statement

Given an H × W grayscale integer image, return a new W × H image rotated 90 degrees clockwise.

Function

rotateClockwise(image: int[][]) → int[][]

Examples

Example 1

image = [[1,2,3],[4,5,6]]return = [[4,1],[5,2],[6,3]]

The first output row is the original first column read bottom to top.

Constraints

  • 1 <= H, W <= 200.
  • Every row has exactly W entries.

More Luma AI problems

See Luma AI hiring insights
public int[][] rotateClockwise(int[][] image) {
    // Return a 90-degree clockwise rotation.
}
image[[1,2,3],[4,5,6]]
expected[[4,1],[5,2],[6,3]]
Checking account…