摘要: 使用了HashMap和排序,此题就没啥了。在长度一定范围的情况下,用26*的方式做key会更好。注意两点:1. java的遍历是for和: 2. map.keySet()public class Solution { public ArrayList anagrams(String[] str... 阅读全文
posted @ 2013-09-22 20:05 阿牧遥 阅读(241) 评论(0) 推荐(1)
摘要: 这种题目有了正确的方法就能简单很多。这道题目是先做对角线的交换,然后上下交换。要注意的是,如果对角线交换,等号两边的i和j肯定是交换的(m[i][j]和m[j][i])public class Solution { public void rotate(int[][] matrix) { int len = matrix.length; for (int i = 0; i < len; i++) { for (int j = 0; j < len-i; j++) { int... 阅读全文
posted @ 2013-09-22 19:09 阿牧遥 阅读(227) 评论(0) 推荐(1)