摘要:
剑指offer 26,27,28 这三道题代码结构相似,可以放在一起练习。 剑指offer 28 对称的二叉树 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; 阅读全文
摘要:
首先将dfs代码贴出来。然后再结合leetcode200 Number of Islands 和 leetcode130 Surrounded Regions 这两道题看具体应用 dfs代码如下: public void dfs(char[][] grid, int i, int j){ if(i 阅读全文
摘要:
4种解法 1.pop count public class Solution { public int[] countBits(int num) { int[] ans = new int[num + 1]; for (int i = 0; i <= num; ++i) ans[i] = popco 阅读全文