PikachuBLOG


  • 首页

  • 分类

  • 归档

  • 标签

  • 搜索

107. Binary Tree Level Order Traversal II

发表于 2017-08-14 | 分类于 LeetCode | 阅读次数
字数统计 405 | 阅读时长 2

107. Binary Tree Level Order Traversal II

Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
For example:
Given binary tree [3,9,20,null,null,15,7],

3
/ \
9 20
/ \
15 7
return its bottom-up level order traversal as:
[
[15,7],
[9,20],
[3]
]
阅读全文 »

106. Construct Binary Tree from Inorder and Postorder Traversal

发表于 2017-08-14 | 分类于 LeetCode | 阅读次数
字数统计 598 | 阅读时长 3

106. Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree.

Note:
You may assume that duplicates do not exist in the tree.

阅读全文 »

105. Construct Binary Tree from Preorder and Inorder Traversal

发表于 2017-08-14 | 分类于 LeetCode | 阅读次数
字数统计 456 | 阅读时长 2

105. Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree.

Note:
You may assume that duplicates do not exist in the tree.

阅读全文 »

104. Maximum Depth of Binary Tree

发表于 2017-08-14 | 分类于 LeetCode | 阅读次数
字数统计 246 | 阅读时长 1

104. Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

阅读全文 »

103. Binary Tree Zigzag Level Order Traversal

发表于 2017-08-14 | 分类于 LeetCode | 阅读次数
字数统计 313 | 阅读时长 2

103. Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).

For example :
Given binary tree[3, 9, 20, null, null, 15, 7],

1
2
3
4
5
6
7
8
9
10
11
   3
  / \
9 20
/ \
15 7
return its zigzag level order traversal as :
[
[3],
[20, 9],
[15, 7]
]
阅读全文 »

C++ const 用法

发表于 2017-08-13 | 分类于 C++ | 阅读次数
字数统计 1,034 | 阅读时长 4

C++ const 用法

  关于指针,主要注意四个方面:指针类型、指针指向类型、指针的值、指针指向的值。当const修饰的是指针类型,那么指针的值就不能改变,即不能指向其他内存空间,但是可以通过指针修改其指向内存空间里面的值。当const修饰是指针指向的内存空间时,那么指针可以指向其他内存空间,但是不能通过指针修改指针所指向内存空间里面的值。

  C++ const 允许指定一个语义约束,编译器会强制实施这个约束,允许程序员告诉编译器某值是保持不变的。如果在编程中确实有某个值保持不变,就应该明确使用const,这样可以获得编译器的帮助。

阅读全文 »

102. Binary Tree Level Order Traversal

发表于 2017-08-12 | 分类于 LeetCode | 阅读次数
字数统计 348 | 阅读时长 2

102. Binary Tree Level Order Traversal

Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).

For example:
Given binary tree [3,9,20,null,null,15,7],
   3
  /  \
  9  20
  / \
 15 7

return its level order traversal as:
[
 [3],
 [9,20],
 [15,7]
]

阅读全文 »

101. Symmetric Tree

发表于 2017-08-12 | 分类于 LeetCode | 阅读次数
字数统计 606 | 阅读时长 3

101. Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
101-1-Symmetric-Tree
But the following [1,2,2,null,3,null,3] is not:
101-2-Symmetric-Tree
Note:
Bonus points if you could solve it both recursively and iteratively.

阅读全文 »

100. Same Tree

发表于 2017-08-12 | 分类于 LeetCode | 阅读次数
字数统计 319 | 阅读时长 2

100. Same Tree

Given two binary trees, write a function to check if they are equal or not.

Two binary trees are considered equal if they are structurally identical and the nodes have the same value.

阅读全文 »

99. Recover Binary Search Tree

发表于 2017-08-12 | 分类于 LeetCode | 阅读次数
字数统计 1,066 | 阅读时长 4

99. Recover Binary Search Tree

Two elements of a binary search tree(BST) are swapped by mistake.
Recover the tree without changing its structure.

Note:
A solution using O(n) space is pretty straight forward.Could you devise a constant space solution ?

阅读全文 »
1…789…17
CodePikachu

CodePikachu

技术随笔

168 日志
5 分类
7 标签
RSS
GitHub Twitter 微博 知乎
0%
© 2015 - 2020 CodePikachu
博客全站共123.3k字
本站访客数:
由 Hexo 强力驱动
主题 - NexT.Pisces