2014年10月9日

树相关的笔试面试题目汇总

摘要: 01. 排序二叉树转换双向链表02. 树中两个节点的最近公共祖先03. 二叉树中序遍历的下一个节点04. 判断一棵树是否为对称二叉树05. 二叉树同一层从左到右打印06. 之字形顺序打印二叉树07. 序列化二叉树08. 二叉搜索树的第K个节点09. 二叉树每层节点连接起来 O(1)空间(注意:递归的... 阅读全文

posted @ 2014-10-09 21:00 雨歌_sky 阅读(374) 评论(0) 推荐(0) 编辑

2014年10月7日

leetcode -- Binary Tree Maximum Path Sum

摘要: 过去只是人生经历,并不是人生负担[问题描述]Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below bi... 阅读全文

posted @ 2014-10-07 11:18 雨歌_sky 阅读(141) 评论(0) 推荐(0) 编辑

2014年10月6日

leetcode -- Palindrome Partitioning II

摘要: 指责别人,看清自己[问题描述]Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome p... 阅读全文

posted @ 2014-10-06 23:13 雨歌_sky 阅读(143) 评论(0) 推荐(0) 编辑

leetcode -- Palindrome Partitioning

摘要: 谋事在人,成事在天[问题描述]Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.F... 阅读全文

posted @ 2014-10-06 22:51 雨歌_sky 阅读(174) 评论(0) 推荐(0) 编辑

leetcode -- Clone Graph

摘要: 不要晃荡,找准方向[问题描述]Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes a... 阅读全文

posted @ 2014-10-06 21:17 雨歌_sky 阅读(135) 评论(0) 推荐(0) 编辑

2014年9月30日

二叉搜索树转换成双向链表

摘要: 好一点点就是好一点点嘛RT传入3个参数 。Yahoo二面被问到!完跪.... 1 void BST2DoubleList(TreeNode *root, TreeNode *& prev, TreeNode *& head) { 2 if (root == NULL) 3 return;... 阅读全文

posted @ 2014-09-30 21:59 雨歌_sky 阅读(235) 评论(0) 推荐(0) 编辑

2014年9月28日

给定一颗完全二叉树,给每一层添加上next的指针,从左边指向右边

摘要: 给你机会发出声音,但是不给你机会证明高层的决定是错的RT: 时间复杂度O(n) 空间复杂度O(1)原理就是有指针指向父节点和当前的节点,左孩子必指向右孩子,右孩子必指向父节点的下一个节点的左孩子void Solution::yahooTree(TreeNode *root){ if (root... 阅读全文

posted @ 2014-09-28 13:08 雨歌_sky 阅读(612) 评论(1) 推荐(0) 编辑

2014年8月15日

leetcode -- Merge Sorted Array

摘要: 过去已无法改变,未来又难以琢磨,我们只能把握当下[问题描述]Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space ... 阅读全文

posted @ 2014-08-15 20:21 雨歌_sky 阅读(116) 评论(0) 推荐(0) 编辑

leetcode -- Merge Intervals

摘要: 关键不是怎么想,而是怎么做[问题描述]Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15... 阅读全文

posted @ 2014-08-15 20:03 雨歌_sky 阅读(122) 评论(0) 推荐(0) 编辑

logn的斐波那契

摘要: This another O(n) which relies on the fact that if we n times multiply the matrix M = {{1,1},{1,0}} to itself (in other words calculate power(M, n )),... 阅读全文

posted @ 2014-08-15 15:13 雨歌_sky 阅读(227) 评论(0) 推荐(0) 编辑

导航