public static ArrayList<Integer> spiralOrderHelper(int[][] matrix, int x,
			int y, int[][] matrixHelper) {
		ArrayList<Integer> newList = new ArrayList<Integer>();
		// if(x > matrix[0].length/2 || y> matrix.length/2 ){
		// return newList;
		// }
		// top
		for (int i = x; i < matrix[0].length - x; i++) {
			if (matrixHelper[y][i] == 1)
				return newList;
			newList.add(matrix[y][i]);
			matrixHelper[y][i] = 1;
		}
		// right
		for (int i = y + 1; i < matrix.length - y; i++) {
			if (matrixHelper[i][matrix[0].length - x - 1] == 1)
				return newList;
			newList.add(matrix[i][matrix[0].length - x - 1]);
			matrixHelper[i][matrix[0].length - x - 1] = 1;
		}
		// bot
		for (int i = matrix[0].length - x - 1 - 1; i > x - 1; i--) {
			if (matrixHelper[matrix.length - y - 1][i] == 1)
				return newList;
			newList.add(matrix[matrix.length - y - 1][i]);
			matrixHelper[matrix.length - y - 1][i] = 1;
		}
		// left
		for (int i = matrix.length - y - 1 - 1; i > y; i--) {
			if (matrixHelper[i][x] == 1)
				return newList;
			newList.add(matrix[i][x]);
			matrixHelper[i][x] = 1;
		}
		return newList;
	}