Solve "rotate matrix 90 degrees" CareerCup problem