摘要:
第一个是用了hashmap, 第二个是在每个结点后面加一个新的结点public class Solution { public RandomListNode copyRandomList(RandomListNode head) { if (head == null) { ... 阅读全文
摘要:
public class Solution { public List getSkyline(int[][] buildings) { List height = new ArrayList(); List result = new ArrayList(); ... 阅读全文
摘要:
单纯的dfs,感觉应该有更好的办法public class Solution { public void solveSudoku(char[][] board) { helper(board); } public boolean helper(char[][] boa... 阅读全文
摘要:
public class Solution { public void connect(TreeLinkNode root) { if (root == null) { return; } TreeLinkNode pre = r... 阅读全文
摘要:
之前写了个很复杂的办法,后来参考网上思路,觉得这个是最简便的写法了public class Solution { public String numberToWords(int num) { String[] first = "Zero One Two Three Four Fi... 阅读全文
摘要:
public class Solution { public void rotate(int[] nums, int k) { int length = nums.length; k = k % length; reverse(nums, 0, len... 阅读全文
摘要:
public class Solution { public List spiralOrder(int[][] matrix) { List result = new ArrayList(); int row = matrix.length; if (... 阅读全文
摘要:
public class Solution { private char[][] board; private List result = new ArrayList(); public List findWords(char[][] board, String[]... 阅读全文
摘要:
动规public class Solution { public boolean isInterleave(String s1, String s2, String s3) { int length1 = s1.length(); int length2 = s2.... 阅读全文
摘要:
这个题目主要是需要处理两个数长度不一样的情况,有两个解决办法。我是采用递归,把长的那一段与carray再加。也可以把短的前面补0.public class Solution { public String addBinary(String a, String b) { int p... 阅读全文