码迷,mamicode.com
首页 >  
搜索关键字:validate binary sear    ( 13532个结果
leetcode-----110. 平衡二叉树
链接:https://leetcode-cn.com/problems/balanced-binary-tree/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; ...
分类:其他好文   时间:2020-07-26 00:05:02    阅读次数:58
LeetCode 102. 二叉树的层序遍历 Java
这个层序遍历要求返回每层的节点,正常的BFS从队列中弹出一个节点后就判断其有没有左子树和右子树,所以直接用BFS实现的话无法分层输出。 需要记录每层的节点数目,增加一个for循环就可以了。 /** * Definition for a binary tree node. * public class ...
分类:编程语言   时间:2020-07-25 23:51:28    阅读次数:72
[LeetCode 68] Text Justification
Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justif ...
分类:其他好文   时间:2020-07-25 09:35:28    阅读次数:71
php excel的使用
1. 引入类 use PHPExcel; use PHPExcel_IOFactory; use PHPExcel_Reader_Excel5; use PHPExcel_Reader_Excel2007; use PHPExcel_RichText; 2导入 /** * PHPexcel导入 */ ...
分类:Web程序   时间:2020-07-24 16:51:05    阅读次数:93
python os模块
导入模块后,可以使用模块提供的通用变量获取与系统有关的信息 >>> import os >>> len(dir(os)) 152 >>> for i in dir(os):print(i) DirEntry F_OK MutableMapping O_APPEND O_BINARY O_CREAT ... ...
分类:编程语言   时间:2020-07-24 09:47:07    阅读次数:86
二叉树中和为某一值的路径
解题:前序遍历加上筛选 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = ...
分类:其他好文   时间:2020-07-23 23:27:44    阅读次数:132
计算机的基本存储单位
一、计算机的存储单位有哪些 计算机存储单位一般用bit,Byte,KB,MB,GB,TB,PB,EB,ZB,BB来表示,我们经常将Byte简称为B,将KB简称为K。 二、存储单位之间的换算关系 1、计算机存储信息的最小单位:位 bit (比特) (Binary Digits):存放一位二进制数,即 ...
分类:其他好文   时间:2020-07-23 22:23:51    阅读次数:224
二叉树最近公共祖先
思路:后序遍历, 分情况讨论: 1、两个节点在根的左侧 2、两个节点在根的右侧 3、两个节点在根的左右两侧 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * ...
分类:其他好文   时间:2020-07-23 22:15:14    阅读次数:77
重建二叉树—递归
二叉树重建 问题:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重 复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。 解决: #递归一 # class Tree ...
分类:其他好文   时间:2020-07-23 16:17:32    阅读次数:71
LC1008 Construct Binary Search Tree from Preorder Traversal
根据BST的前序遍历重建BST 1. 平均O(NlogN) 最坏O(N^2) class Solution { public: TreeNode* dfs(int l, int r, vector<int>& p) { if (l > r) return nullptr; TreeNode* nod ...
分类:其他好文   时间:2020-07-23 16:13:09    阅读次数:67
13532条   上一页 1 ... 24 25 26 27 28 ... 1354 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!