摘要: 和Spiral Matrix是一样的,这题还简单一点 1 public int[][] generateMatrix(int n) { 2 int[][] res = new int[n][n]; 3 if(n <= 0) { 4 return res; 5 } 6 int layer = n / 阅读全文
posted @ 2016-03-04 07:31 warmland 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 就是实现题。于是我用了一个半小时 = =心好累 如果layer数是奇数的时候要多处理一下 1 public List<Integer> spiralOrder(int[][] matrix) { 2 List<Integer> res = new ArrayList<Integer>(); 3 if 阅读全文
posted @ 2016-03-04 07:03 warmland 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 思路: 对于数列里的每一个数,从头到尾扫一遍,每一个位置上的数能够达到最远的地方,就是这个位置加上这个位置可以走的最远的位置。 再维持一个目前为止的最大值,如果目前的位置已经超过了曾经有过的最大的值,那么就结束,返回false。 如果全局的最大值已经能够达到数列的末尾,那么就返回true。 1 pu 阅读全文
posted @ 2016-03-04 04:36 warmland 阅读(149) 评论(0) 推荐(0) 编辑