题目描述: 给定一个二叉树,检查它是否是镜像对称的。例如,二叉树 [1,2,2,3,4,4,3] 是对称的。 DFS:递归,和100题相同的树类似,不过要注意是左右子树进行比较 //C //注意这个函数声明 bool isMirroTree(struct TreeNode* p, struct Tr ...
分类:
其他好文 时间:
2020-06-13 11:25:28
阅读次数:
56
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = Nonefrom typing import Listclass Solution: # 迭代的想法 def levelOrderBot ...
分类:
其他好文 时间:
2020-06-13 00:42:24
阅读次数:
46
题目描述: 给定两个二叉树,编写一个函数来检验它们是否相同。如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 深度优先遍历,递归或者用栈 //C //递归 bool isSameTree(struct TreeNode* p, struct TreeNode* q){ if(p = ...
分类:
其他好文 时间:
2020-06-12 14:24:15
阅读次数:
43
最近做项目时约到一个需求就是要求2019年的12个月中只能选择其中的某些月份,其他月份不可选择,对于2018年的月份全部不可选,2020年以及以后的全部可选, 即效果如下: 参考了网上的一些资料以后,做了代码的修改,实现了以上功能 function styleMonthDate(db,sdate,m ...
分类:
其他好文 时间:
2020-06-12 14:12:55
阅读次数:
71
题目: 思路: 因为要求每层节点打印到一行,所以层次遍历时需要知道行的信息。个人思路通过两个队列的转换表示换行,优化思路记录当前层队列的长度。 代码: Python # Definition for a binary tree node. # class TreeNode(object): # de ...
分类:
其他好文 时间:
2020-06-09 16:56:07
阅读次数:
49
class Solution(object): def isSameTree(self, p, q): """ :type p: TreeNode :type q: TreeNode :rtype: bool """ # 根节点值不同,树不同 if p.val != q.val: return Fa ...
分类:
其他好文 时间:
2020-06-08 14:46:48
阅读次数:
57
在【javaweb解决上传文件目录问题【*****】】的基础上做。 1、实现动态加载后台数据,并且显示照片。 表映射类: package table; public class ImagePath { //用来存放文件路径的文件名 private String path; /** * @return ...
分类:
其他好文 时间:
2020-06-05 15:11:04
阅读次数:
53
easyui vue 版本 官方网站 http://www.jeasyui.net/vue 安装 npm install vx-easyui --save 如何引用? 当然是查看下载的包种的 readme文档 在main.js 引入 // import 'vx-easyui/dist/themes/ ...
分类:
其他好文 时间:
2020-06-04 14:01:35
阅读次数:
182
题目如下: Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Retur ...
分类:
其他好文 时间:
2020-06-04 10:33:57
阅读次数:
77
先来一个前序遍历把所有结点存在一个列表中,然后遍历链表,把所有结点用右指针串起来 1 /** 2 * Definition for a binary tree node. 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * ...
分类:
其他好文 时间:
2020-05-30 22:05:09
阅读次数:
83