摘要:
像这种DFS相关的题型,重点还是要知道如何进行标记。我就是卡在这里顺不下去,难过死了…… public int closedIsland(int[][] grid) { int sum = 0; for(int i = 1;i<grid.length;i++){ for(int j = 1;j<gr 阅读全文
摘要:
public int[] pondSizes(int[][] land) { List<Integer> list = new ArrayList<>(); int temp; for (int i = 0; i < land.length; i++) { for (int j = 0; j < l 阅读全文
摘要:
public TreeNode recoverFromPreorder(String S) { Stack<TreeNode> path = new Stack<>(); //构建好栈 //定义一个变量来遍历S int i = 0; //定义一个int变量来确定节点的层数 //先将S转换成char[ 阅读全文
摘要:
private final static int MAXVALUE = 1000; public int networkDelayTime(int[][] times, int N, int K) { boolean[] visited = new boolean[N+1]; int[][] tim 阅读全文