摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2014-10-21 21:53 非著名程序师 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 给定一个二叉树,以集合方式返回其中序/先序方式遍历的所有元素。有两种方法,一种是经典的中序/先序方式的经典递归方式,另一种可以结合栈来实现非递归Given a binary tree, return theinordertraversal of its nodes' values.For examp... 阅读全文
posted @ 2014-10-21 21:44 非著名程序师 阅读(559) 评论(0) 推荐(0) 编辑
摘要: Given two binarytrees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and... 阅读全文
posted @ 2014-10-21 21:37 非著名程序师 阅读(754) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?注意,链表循环并不是尾指针和头指针相同,可能是在中间某一段形成一个环路,所以不能只判... 阅读全文
posted @ 2014-10-21 21:35 非著名程序师 阅读(1175) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321本地注意正负号判断比较关键,实现部分可能不是最优的,按照自己的想法实现:设ret = 1;每次对x进行取余mod,然后ret ... 阅读全文
posted @ 2014-10-21 21:31 非著名程序师 阅读(261) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree,find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest lea... 阅读全文
posted @ 2014-10-21 21:25 非著名程序师 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
posted @ 2014-10-21 21:22 非著名程序师 阅读(432) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文
posted @ 2014-10-21 21:07 非著名程序师 阅读(223) 评论(0) 推荐(0) 编辑