Algorithms—54.Spiral Matrix

public class Solution {
public List<Integer> spiralOrder(int[][] matrix) {
List<Integer> list=new ArrayList<Integer>();
//m:行，n列
int mb=0;
int nb=0;
int me=matrix.length;
if (me==0) {
return list;
}
int ne=matrix[0].length;
while (true) {
list=new Solution().right(matrix, mb, nb, me, ne, list);
mb++;
if (nb>ne-1||mb>me-1) {
return list;
}
list=new Solution().low(matrix, mb, nb, me, ne, list);
ne--;
if (nb>ne-1||mb>me-1) {
return list;
}
list=new Solution().left(matrix, mb, nb, me, ne, list);
me--;
if (nb>ne-1||mb>me-1) {
return list;
}
list=new Solution().up(matrix, mb, nb, me, ne, list);
nb++;
if (nb>ne-1||mb>me-1) {
return list;
}
}
}
public List<Integer> right(int[][] matrix,int mb,int nb,int me,int ne,List<Integer> list){
for (int i = nb; i < ne; i++) {
}
return list;
}
public List<Integer> left(int[][] matrix,int mb,int nb,int me,int ne,List<Integer> list){
for (int i = ne-1; i >=nb; i--) {
}
return list;
}
public List<Integer> low(int[][] matrix,int mb,int nb,int me,int ne,List<Integer> list){
for (int i = mb; i < me; i++) {
}
return list;
}
public List<Integer> up(int[][] matrix,int mb,int nb,int me,int ne,List<Integer> list){
for (int i = me-1; i >=mb; i--) {
}
return list;
}
}

Optimization Algorithms on Matrix Manifolds

2016年11月20日 7.69MB 下载

01-18 430

11-22 255

03-01 73

06-13 9974

Algorithms for Non-negative Matrix Factorization

2016年07月11日 1.07MB 下载

06-13 4869

05-09 258

02-05 1185

09-08 61