How to solve "Matrix Layer Rotation" on HackerRank

T he challenge is to split a matrix into concentric rings, and rotate each ring a certain number of places to the left. To do that, all we really need to do is figure out how to look at each ring as if it were a flat array. That can be broken down into two challenges: the mathematics, and the code. The mathematics We’re given a matrix M \mathbf{M} M of width w w w and height h h h . We want to…