TikTok OA Interview Question: Rotate a Single-Channel Grayscale Image by 90 Degrees

17 Views
No Comments

Assignment: Write a piece of code which takes a single-channel grayscale image as an input and rotates it by 90 degrees.

This problem asks you to rotate a single-channel grayscale image by 90 degrees, which is equivalent to transforming a 2D matrix. The standard approach is to transpose the matrix and then reverse rows or columns depending on the rotation direction. The key is to map pixel positions correctly while handling the changed dimensions, with an O(mn) traversal in most solutions.

END
 0