This is one of those relatively tricky interview questions which mostly need some mathematical and logical thinking, not much more. I don't like such questions much, but it's not that bad...
OP just need to think...
I have only one advice to OP: don't give up. Not a rocket surgery, by the way...
—SA

Thank you for asking, I'll gladly answer you, but I'm a bit confusing: which one, literally?
If this is "rocket surgery", this is intentional, and not my invention. Or are you talking about something else? What's "off-key"?
—SA

The "idom" in question is "it/smth. is not exactly rocket science". So it's actually in science and not "surgery". A couple a days ago you wrote "rocker science", but I'm sorry to say I can longer find that comment of yours. I hope the question wasn't deleted.

[Edit]: Feel free to chastise me. I just googled "rocket surgery" and was astonished to find it really exists as a take on two metaphors concerning "Rocket Science" and "Brain Surgery". Sort of a malapropism if you like.[/edit]

Well-known saying, in fact; unfortunately, I don't even remember where I picked it up.
By they way, this is not an idiom, but rather a meme... And a malapropism, yes.
Thank you for your interest to this matter. I really like a good to-the-point word... ;-)
—SA

No, as I said, a few days ago you wrote "rocker surgery", but alas that comment is no longer to be found.
Indeed, it isn't an idiom at all since "rocket science" makes sense when translated to many languages (German for instance).
"Metaphor" was the word I was groping about for. :)

1 solution

Solution 1

See the matrix as a set of nested squares. You can rotate each square independently. To rotate a square by N positions, you can rotate it N times by one position. To rotate by one position, save one element to extra storage, shift the others circularly and put back the saved element.