摘要:
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
摘要:
给定一个二叉树,以集合方式返回其中序/先序方式遍历的所有元素。有两种方法,一种是经典的中序/先序方式的经典递归方式,另一种可以结合栈来实现非递归Given a binary tree, return theinordertraversal of its nodes' values.For examp... 阅读全文
摘要:
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... 阅读全文
摘要:
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?注意,链表循环并不是尾指针和头指针相同,可能是在中间某一段形成一个环路,所以不能只判... 阅读全文
摘要:
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321本地注意正负号判断比较关键,实现部分可能不是最优的,按照自己的想法实现:设ret = 1;每次对x进行取余mod,然后ret ... 阅读全文
摘要:
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... 阅读全文
摘要:
Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
摘要:
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... 阅读全文