kevin55

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

01 2016 档案

摘要:从root开始遍历,如果n1和n2中的任一个和root匹配,那么root就是LCA。 如果都不匹配,则分别递归左、右子树,如果有一个 key(n1或n2)出现在左子树,并且另一个key(n1或n2)出现在右子树,则root就是LCA. 如果两个key都出现在左子树,则说明LCA在左子树中,否则在右子... 阅读全文
posted @ 2016-01-25 18:13 kernel_main 阅读(739) 评论(0) 推荐(0)

摘要:解决二叉树的很多问题的方案都是基于对二叉树的遍历。遍历二叉树的前序,中序,后序三大方法算是计算机科班学生必写代码了。其递归遍历是人人都能信手拈来,可是在手生时写出非递归遍历恐非易事。正因为并非易事,所以网上出现无数的介绍二叉树非递归遍历方法的文章。可是大家需要的真是那些非递归遍历代码和讲述吗?代码早... 阅读全文
posted @ 2016-01-23 19:00 kernel_main 阅读(877) 评论(0) 推荐(0)

摘要:#include "List.h"#include #include using namespace std;#define max(a, b) (a) > (b) ? (a) : (b)// LeetCode, Longest Substring Without Repeating Charact... 阅读全文
posted @ 2016-01-22 23:57 kernel_main 阅读(166) 评论(0) 推荐(0)

摘要:// TwoNum.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include using namespace std;//Definition for singly... 阅读全文
posted @ 2016-01-22 18:26 kernel_main 阅读(217) 评论(0) 推荐(0)

摘要:#ifndef List_h__#define List_h__#include struct ListNode{ int value; ListNode* pNext; ListNode(int n) :value(n), pNext(nullptr){}};class List... 阅读全文
posted @ 2016-01-21 22:04 kernel_main 阅读(415) 评论(0) 推荐(0)

摘要:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... 阅读全文
posted @ 2016-01-19 22:21 kernel_main 阅读(178) 评论(0) 推荐(0)

摘要:先看下面代码:#include #include #include class Test{public: Test(int i) :a(i) { } ~Test() { }public: void Print() { pri... 阅读全文
posted @ 2016-01-12 23:32 kernel_main 阅读(652) 评论(0) 推荐(0)