码迷,mamicode.com
首页 >  
搜索关键字:zigzag level order t    ( 24142个结果
Leetcode 树 Binary Tree Zigzag Level Order Traversal
题意:给定一棵二叉树,返回按zigzag层次遍历的结果 思路: 还是跟前面的Binary Tree Level Order Traversal的思路一样 即从上往下按层遍历二叉树,将每一层的节点存放到该层对应的数组中 最后将得到的总数组中奇数层(从0层开始计数)的子数组reverse一下就可以了 复杂度:时间O(n),空间O(n)...
分类:其他好文   时间:2014-05-15 15:15:50    阅读次数:374
Leetcode 树 Binary Tree Level Order Traversal
题意:给定一棵二叉树,返回按层遍历的结果 思路1:bfs,定义一个新的struct,记录指针向节点的指针和每个节点所在的层 复杂度1:时间O(n),空间O(n) 思路2:dfs 递归函数: void levelOrder(TreeNode *root, int level, vector<vector >&result) 表示把根为root的树按层存放在result中,其中level表示当前的层数 复杂度2:时间O(n),空间O(n) 相关题目:...
分类:其他好文   时间:2014-05-15 14:46:06    阅读次数:355
Linux下chkconfig命令详解
chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。使用语法:chkconfig [--add][--del][--list][系统服务] 或 chkconfig [--level ][系统服务...
分类:系统相关   时间:2014-05-15 10:28:17    阅读次数:406
C++生成zigzag矩阵
C++生成zigzag矩阵...
分类:编程语言   时间:2014-05-15 06:43:46    阅读次数:503
Leetcode 树 Binary Tree Level Order Traversal II
题意:从底往上按层遍历二叉树 思路: 思路和Binary Tree Level Order Traveral 一样, 即从上往下按层遍历二叉树,将每一层的节点存放到该层对应的数组中 最后将得到的数组倒转一下就可以了 按层遍历二叉树可用bfs,也可用dfs,但都要记录节点所在的层 复杂度:时间O(n), 空间O(n)...
分类:其他好文   时间:2014-05-15 06:32:14    阅读次数:278
LeetCode-004 Add Two Numbers
【题目】 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Out...
分类:其他好文   时间:2014-05-15 05:13:49    阅读次数:306
Pat(Advanced Level)Practice--1043(Is It a Binary Search Tree)
Pat1043代码 题目描述: A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than t...
分类:其他好文   时间:2014-05-15 05:09:59    阅读次数:351
sql获取每门课程成绩最好的学生信息
1.相关数据表 Score表 [User]表 SQL语句如下: --查询出各科成绩最好的学生信息 --自连接 --SELECT TOP 1 * FROM Score B WHERE B.ScoreName = '数学' ORDER BY B.Score DESC SELECT A.ID,U.Name,A.ScoreName,A.Score FROM Score A,[Use...
分类:数据库   时间:2014-05-15 05:02:05    阅读次数:477
[LeetCode]ZigZag Conversion
Write the code that will take a string and make this conversion given a number of rows: P A H N A P L S I I G Y I R convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR"....
分类:其他好文   时间:2014-05-15 04:49:04    阅读次数:311
Pat(Advanced Level)Practice--1043(Is It a Binary Search Tree)
Pat1043代码题目描述:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contain...
分类:其他好文   时间:2014-05-14 22:03:25    阅读次数:487
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!