摘要: O(n)时间,O(1)空间对二叉树进行前序、中序、后序遍历。详细讲解看参考。public class Solution { public static void morrisPreorder(TreeNode root) { TreeNode cur = root; ... 阅读全文
posted @ 2014-09-09 22:36 jdflyfly 阅读(357) 评论(0) 推荐(0)
摘要: 297. Serialize and Deserialize Binary Tree 思路:preorder遍历 便于deserialize。时空O(N)。 public class Codec { // Encodes a tree to a single string. public Strin 阅读全文
posted @ 2014-09-09 19:41 jdflyfly 阅读(1369) 评论(0) 推荐(0)