剑指offer 二叉搜索树与双向链表
html, body {
font-size: 15px;
}
body {
font-family: Helvetica, "Hiragino Sans GB", 微软雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif;
line-height: 1.6;
color: ;
background-color: ;
margin: 0;
padding: 16px 20px;
}
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
margin: 1.33rem 0 0.667rem;
padding: 0;
font-weight: bold;
}
h1 {
font-size: 21px;
font-size: 1.4rem;
}
h2 {
font-size: 20px;
font-size: 1.33rem;
}
h3 {
font-size: 18px;
font-size: 1.2rem;
}
h4 {
font-size: 17px;
font-size: 1.13rem;
}
h5 {
font-size: 15px;
font-size: 1rem;
}
h6 {
font-size: 15px;
font-size: 1rem;
color: #777777;
margin: 1rem 0;
}
div, p, ul, ol, dl, li {
margin: 0;
}
blockquote, table, pre, code{
margin: 8px 0;
}
ul, ol {
padding-left: 32px;
padding-left: 2.13rem;
}
blockquote {
border-left: 4px solid #dddddd;
padding: 0 12px;
padding: 0 0.8rem;
}
blockquote > :first-child {
margin-top: 0;
}
blockquote > :last-child {
margin-bottom: 0;
}
img {
border: 0;
max-width: 100%;
height: auto !important;
margin: 2px 0;
}
table {
border-collapse: collapse;
border: 1px solid #bbbbbb;
}
td {
padding:4px 8px;
border-collapse: collapse;
border: 1px solid #bbbbbb;
}
@media screen and (max-width: 660px) {
body {
padding: 20px 18px;
padding: 1.33rem 1.2rem;
}
}
@media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) {
html, body {
font-size: 17px;
}
body {
line-height: 1.7;
padding: 0.75rem 0.9375rem;
color: #353c47;
}
h1 {
font-size: 2.125rem;
}
h2 {
font-size: 1.875rem;
}
h3 {
font-size: 1.625rem;
}
h4 {
font-size: 1.375rem;
}
h5 {
font-size: 1.125rem;
}
h6 {
color: inherit;
}
ul, ol {
padding-left: 2.5rem;
}
blockquote {
padding: 0 0.9375rem;
}
}
剑指offer 二叉搜索树与双向链表

|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { }};*/class Solution { public: vector<TreeNode *> m_vector; TreeNode* Convert(TreeNode* pRootOfTree) { if(pRootOfTree==NULL)return NULL; printVector(pRootOfTree); for(int i=0;i<m_vector.size()-1;i++) { m_vector[i]->right=m_vector[i+1]; m_vector[i+1]->left=m_vector[i]; } return m_vector[0]; } void printVector(TreeNode *root) { if(root->left!=NULL) printVector(root->left); m_vector.push_back(root); if(root->right!=NULL) printVector(root->right); }}; |
剑指offer 二叉搜索树与双向链表的更多相关文章
- 剑指offer 二叉搜索树和双向链表
剑指offer 牛客网 二叉搜索树和双向链表 # -*- coding: utf-8 -*- """ Created on Tue Apr 9 18:58:36 2019 ...
- 剑指Offer——二叉搜索树与双向链表
题目描述: 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表.要求不能创建任何新的结点,只能调整树中结点指针的指向. 分析: 二叉搜索树,中序遍历就是排序的. 所以我们利用中序遍历,将前后两 ...
- 用js刷剑指offer(二叉搜索树与双向链表)
题目描述 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表.要求不能创建任何新的结点,只能调整树中结点指针的指向. 牛客网链接 js代码 /* function TreeNode(x) { ...
- [剑指Offer]36-二叉搜索树与双向链表
链接 https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5?tpId=13&tqId=11179&tPa ...
- 剑指Offer-26.二叉搜索树与双向链表(C++/Java)
题目: 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表.要求不能创建任何新的结点,只能调整树中结点指针的指向. 分析: 创建两个指针,分别指向要处理的当前元素和当前元素的前一个元素.利用中 ...
- 剑指Offer 二叉搜索树的后序遍历序列
题目描述 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则输出Yes,否则输出No.假设输入的数组的任意两个数字都互不相同. 思路: 后续遍历数组的尾部为根节点,前面的部分 ...
- 剑指Offer——二叉搜索树的第k个结点
题目描述: 给定一颗二叉搜索树,请找出其中的第k大的结点. 例如, 5 / \ 3 7 /\ /\ 2 4 6 8 中,按结点数值大小顺序第三个结点的值为4 分析: 二叉搜索树中序遍历就是从小到大.只 ...
- 剑指Offer——二叉搜索树的后序遍历序列
题目描述: 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则输出Yes,否则输出No.假设输入的数组的任意两个数字都互不相同. 分析: 二叉查找树(Binary Search ...
- [剑指offer] 二叉搜索树的后序遍历序列 (由1个后续遍历的数组判断它是不是BST)
①题目 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则输出Yes,否则输出No.假设输入的数组的任意两个数字都互不相同. ②思路 1.后续遍历的数组里,最后一个元素是根. 2 ...
随机推荐
- Xcode最最实用快捷键
转发:http://www.open-open.com/lib/view/open1397988745593.html 关于与mac 通用的快捷键网上太多,就不说了,下面介绍一些大家不是很熟悉但是 ...
- php获取当前域名
当前url:http://localhost:805/test/helloworld.php echo 'SERVER_NAME:'.$_SERVER['SERVER_NAME']; //获取当前域名 ...
- 说说final关键字(好像有干货)
在java开发过程中,final是大家常用的关键字,无非就是用来修饰类,方法和变量,来表名类不能被继承,方法不会被覆盖,变量不能被改变,悄悄的说一句,private方法也隐式的final.通过一段时间 ...
- python常用正则表达式
匹配特定数字:^[1-9]\d*//匹配正整数−[1−9]\d∗ //匹配负整数^-?[1-9]\d*//匹配整数[1−9]\d∗|0 //匹配非负整数(正整数 + 0)^-[1-9]\d*|0// ...
- ASP.NET ValidationGroup 属性和CssClass 属性
定义和用法 获取或设置在 Button 控件回发到服务器时要进行验证的控件组. 通常在表单中存在多个按钮时使用该属性. 语法 <asp:Button ValidationGroup=" ...
- 第九节,基本条件语句if
条件语句 如果我们希望有效的响应用户的输入,代码就需要具有判断能力.能够让程序进行判断的结构成为条件,条件判断语句返回的是布尔值真或假,真就执行一条线路,假就执行另外一条线路 注意if判断如果怎样,否 ...
- python 输出重定向
使print既打印到终端,又写入文件 class Tee(object): def __init__(self,*files): self.files = files def write(self,o ...
- Handling Captcha | Webdriver
http://seleniumworks.blogspot.kr/2013/09/handling-captcha-webdriver.html Make use of the 'input' tag ...
- hdu_2089_不要62(数位DP)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2089 题意:中文,不解释 题解:dp[i][j]表示当前第i位的前一个数为j,然后记忆化dfs,注意的 ...
- 素数槽csuoj
超时代码: #include <iostream> using namespace std;//写一个函数判断是否是素数bool isPrime(int num){int i=2;//co ...