Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to rotate a matrix 90 degrees counterclockwise.

Hard

Problem Statement

Write a function to rotate a matrix 90 degrees counterclockwise.

Sample Input

[[1, 2, 3], [4, 5, 6], [7, 8, 9]]

Sample Output

[[7, 4, 1], [8, 5, 2], [9, 6, 3]]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
def rotate_matrix_counterclockwise(): matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # Your code here return
Log in or sign up to run or submit your code.Log inSign up
Input
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Expected Output
[[7, 4, 1], [8, 5, 2], [9, 6, 3]]