Algorithm · Google · Medium
Requirements Rotate a two-dimensional matrix by 90 degrees in the clockwise direction. For a square matrix, perform the transformation in place with constant auxiliary space, O(1). For a rectangular matrix (follow-up), recognize that the usual approach creates a separate matrix with the dimensions swapped. An in-place alternative can follow permutation cycles, but it requires bookkeeping using O(m+n) additional space. Be prepared to discuss rotating by any multiple of 90…
Checking your access…