102-二叉树的层序遍历 给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。 题目分析 此题类似于《剑指offer》的第32题 层序遍历二叉树是指对二叉树每一层从左到右进行访问。 非叶子节点 对于每一层的非叶子节点,都有两个子节点。在层序遍历时,上一层非叶子 ...
分类:
其他好文 时间:
2020-07-17 16:15:17
阅读次数:
50
题目描述: 第一次提交:通过76/78 留坑 class Solution: def isBipartite(self, graph: List[List[int]]) -> bool: dic = {} l = [] for i in range(len(graph)): if graph[i] ...
分类:
其他好文 时间:
2020-07-17 14:14:05
阅读次数:
61
一、Reading After my graduation, I went to Beijing to further my studies. I lived there for three years. At first, I was happy, but later, I was frustra ...
分类:
其他好文 时间:
2020-07-17 14:02:28
阅读次数:
91
题目来源:leetcode64 最小路径和 题目描述: 给定一个包含非负整数的 m x n 网格,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 说明:每次只能向下或者向右移动一步。 示例: 输入: [ [1,3,1], [1,5,1], [4,2,1] ] 输出: 7 解释: 因为 ...
分类:
其他好文 时间:
2020-07-17 13:50:24
阅读次数:
46
BFS 解法: private final void addRow(Stack<TreeNode> stack, int v) { while (!stack.empty()) { TreeNode node = stack.pop(); TreeNode newNodeLeft = new Tre ...
分类:
其他好文 时间:
2020-07-17 13:49:00
阅读次数:
51
######前言:本人第一次刷LeetCode,我是按照题目顺序开始刷的,第一题为“两数之和”、即使难度为“简单”,但仍然花费了很长时间才勉强做出来,为什么说是勉强做出来?因为我仅仅是实现了功能,但是在做法以及时间、空间复杂度上却比较笨重且消耗了大量的资源,但仍然想借此记录一下, 毕竟是耗费了脑细胞 ...
分类:
其他好文 时间:
2020-07-17 09:26:43
阅读次数:
65
package LeetCode_279 import java.util.* import kotlin.collections.HashSet /** * 279. Perfect Squares * https://leetcode.com/problems/perfect-squares/d ...
分类:
其他好文 时间:
2020-07-17 01:15:12
阅读次数:
72
题目链接:https://leetcode-cn.com/problems/n-ary-tree-postorder-traversal/ 方法一递归法:先访问子节点,然后访问根。LeetCode代码: /* // Definition for a Node. class Node { public ...
分类:
其他好文 时间:
2020-07-16 21:39:10
阅读次数:
79
785. 判断二分图 题目来源:力扣(LeetCode)https://leetcode-cn.com/problems/is-graph-bipartite 题目 给定一个无向图 graph,当这个图为二分图时返回 true。 如果我们能将一个图的节点集合分割成两个独立的子集 A和 B,并使图中的 ...
分类:
编程语言 时间:
2020-07-16 21:03:51
阅读次数:
60
赖世雄美语从头学初级美语 初级美语 L001:Self Introduction 解析 ...
分类:
其他好文 时间:
2020-07-16 21:01:01
阅读次数:
44