码迷,mamicode.com
首页 >  
搜索关键字:binary tree zigzag l    ( 23541个结果
Symmetric Tree
题目 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / 2 2 / \ / 3 4 4 3 ...
分类:其他好文   时间:2014-06-08 18:12:04    阅读次数:248
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: G...
分类:其他好文   时间:2014-06-08 17:29:07    阅读次数:315
Binary Tree Inorder Traversal
1. 递归解法 /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cl...
分类:其他好文   时间:2014-06-08 16:51:59    阅读次数:199
LeetCode: Populating Next Right Pointers in Each Node II [117]
【题目】 Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extra space. For example, Given the following binary tre...
分类:其他好文   时间:2014-06-08 15:46:22    阅读次数:303
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. Cou...
分类:其他好文   时间:2014-06-08 15:32:45    阅读次数:245
extjs tree check 级联选择
extjs4 tree check 级联选择 实现效果:关键代码: function changeAllNode(node, isCheck) { allChild(node, isCheck); allParent(node, isCheck); function allChild(nodec, isCheckc) { var chileNodes = n...
分类:Web程序   时间:2014-06-08 15:25:20    阅读次数:222
Binary Tree Preorder Traversal
1. 递归解法 2. 非递归解法(空间复杂度O(n)和O(1))...
分类:其他好文   时间:2014-06-08 10:47:37    阅读次数:139
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. 方法 使用DFS对树进行遍...
分类:其他好文   时间:2014-06-08 10:26:33    阅读次数:207
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). For example: Given binary tree {3,9,20...
分类:其他好文   时间:2014-06-08 09:23:34    阅读次数:230
[LeetCode] ZigZag Conversion [9]
题目:convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR". 解题思路:这个是个纯粹找规律的题,其他没啥特殊的。下面的例子nRows=4; 找规律按照数组小标开始,寻找下标出现的规律, 1. 第一行和最后一行相邻元素下标之差为 2*nRows-2; 2. 除过第一行和最后一行,其余行要多一个元素,该元素出现的下标和行号有关,比如5 = 1 + 6 - 2,可以总结出规律为 j + 2*nRows-2 - 2*i; 关于 i 和 j 看以看下面...
分类:其他好文   时间:2014-06-08 09:11:57    阅读次数:230
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!