import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * Created by william on 12/8/2015.
 */
public class Solution {

    public static void main(String[] args) {

    }

    public static final class Point {
        int row;
        int col;
        int val;

        public Point(int r, int c, int v) {
            super();
            this.row = r;
            this.col = c;
            this.val = v;
        }

    }

    public static final class Resolver {
        public static int[][] resolve(int numOfRow, int numOfCol, int step, int[][] matrix) {
            int numOfLevel = Math.min(numOfRow, numOfCol) / 2;
            int[][] output = new int[numOfRow][numOfCol];
            IntStream.range(0, numOfLevel).mapToObj(level -> {
                int top = (numOfRow - 1) - level;
                int button = level;
                int left = level;
                int right = (numOfCol - 1) - level;

                return Stream.concat(
                        Stream.<Point>concat(
                                IntStream.range(left, right).mapToObj(col -> new Point(button, col, matrix[button][col])),
                                IntStream.range(button, top).mapToObj(row -> new Point(row, right, matrix[row][right]))),
                        Stream.<Point>concat(
                                IntStream.range(left, right).mapToObj(col -> new Point(top, (numOfCol - 1 - col), matrix[top][numOfCol - 1 - col])),
                                IntStream.range(button, top).mapToObj(row -> new Point((numOfRow - 1 - row), left, matrix[numOfRow - 1 - row][left]))))
                        .collect(Collectors.toList());
            }).forEach(ring -> {
                for (int i = 0; i < ring.size(); i++) {
                    final Point point = ring.get(i);
                    output[point.row][point.col] = ring.get((i + step) % ring.size()).val;
                }
            });

            return output;
        }
    }
}

@@ -14,25 +14,15 @@
 til.
-stream.Collectors
+Scanner
 ;%0Aim
@@ -152,24 +152,24 @@
 Solution %7B%0A%0A
-
     public s
@@ -200,16 +200,776 @@
  args) %7B
+%0A        try (final Scanner scanner = new Scanner(System.in)) %7B%0A            final int numOfRow = scanner.nextInt();%0A            final int numOfCol = scanner.nextInt();%0A            final int numOfStep = scanner.nextInt();%0A%0A            final int%5B%5D%5B%5D matrix = IntStream.range(0, numOfRow).mapToObj(row -%3E%0A                    IntStream.range(0, numOfCol).map(col -%3E scanner.nextInt()).toArray()%0A            ).toArray(int%5B%5D%5B%5D::new);%0A%0A            final int%5B%5D%5B%5D output = Resolver.resolve(numOfRow, numOfCol, numOfStep, matrix);%0A            for (int i = 0; i %3C numOfRow; i++) %7B%0A                for (int j = 0; j %3C numOfCol; j++) %7B%0A                    System.out.print(output%5Bi%5D%5Bj%5D + %22 %22);%0A                %7D%0A                System.out.println();%0A            %7D%0A        %7D
 %0A%0A    %7D%0A
@@ -2417,35 +2417,28 @@
    .
-collect(Collectors.toList()
+toArray(Point%5B%5D::new
 );%0A 
@@ -2510,22 +2510,22 @@
  %3C ring.
-size()
+length
 ; i++) %7B
@@ -2573,15 +2573,11 @@
 ring
-.get(i)
+%5Bi%5D
 ;%0A  
@@ -2633,13 +2633,9 @@
 ring
-.get(
+%5B
 (i +
@@ -2652,15 +2652,15 @@
 ing.
-size())
+length%5D
 .val

add matrix-rotation-algo problem