题意: 给一棵满二叉树,要求将每层的节点从左到右用next指针连起来,层尾指向NULL即可。思路: 可以递归也可以迭代。需要观察到next的左孩子恰好就是本节点的右孩子的next啦。 (1)递归:这个更快。 1 /** 2 * Definition for binary tree with ...
分类:
其他好文 时间:
2015-11-04 00:26:29
阅读次数:
197
递归实现如下: public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if(p.val>root.val&&q.val>root.val) return lowestComm...
分类:
编程语言 时间:
2015-11-03 21:10:51
阅读次数:
267
题意: 给出一个二叉树,输出根到所有叶子节点的路径。思路: 直接DFS一次,只需要判断是否到达了叶子,是就收集答案。 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; ...
分类:
其他好文 时间:
2015-11-03 21:01:00
阅读次数:
206
Description:Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory...
分类:
其他好文 时间:
2015-11-03 20:51:35
阅读次数:
278
摘自:http://www.cnblogs.com/ider/archive/2012/04/01/binary_search.html在学习算法的过程中,我们除了要了解某个算法的基本原理、实现方式,更重要的一个环节是利用big-O理论来分析算法的复杂度。在时间复杂度和空间复杂度之间,我们又会更注重...
分类:
其他好文 时间:
2015-11-03 12:16:43
阅读次数:
270
题意: 用迭代法输出一棵二叉树的后序遍历结果。思路: (1)用两个栈,一个存指针,一个存标记,表示该指针当前已经访问过哪些孩子了。 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int ...
分类:
其他好文 时间:
2015-11-02 22:39:45
阅读次数:
259
查看openstack的运行状态novaservice-list+------------------+-------------------------------------+--------------------+---------+-------+----------------------------+-----------------+|Binary|Host|Zone|Status|State|Updated_at|DisabledReason|+----------------..
分类:
其他好文 时间:
2015-11-02 21:25:55
阅读次数:
341
1. TitleRecover Binary Search Tree2. Http addresshttps://leetcode.com/problems/recover-binary-search-tree/3. The questionTwo elements of a binary sear...
分类:
其他好文 时间:
2015-11-01 21:00:19
阅读次数:
168
题目:Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, ...
分类:
其他好文 时间:
2015-11-01 16:26:22
阅读次数:
185
phpunit: #!D:\xampp\php\.\php.exe. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are p...
分类:
Web程序 时间:
2015-11-01 12:44:46
阅读次数:
177