Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and ...
分类:
其他好文 时间:
2014-11-29 06:40:34
阅读次数:
167
Mapping the SwapsSorting an array can be done by swapping certain pairs of adjacent entries in the array. This is the fundamental technique used in th...
分类:
其他好文 时间:
2014-11-28 21:19:28
阅读次数:
245
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2014-11-28 16:26:03
阅读次数:
129
4.7Youhavetwoverylargebinarytrees:T1,withmillionsofnodes,andT2,withhundredsofnodes.CreateanalgorithmtodecideifT2isasubtreeofT1.//Itwilliteratemaintree(millions)nodes.
//Toobad.
booleanisSubTree(Nodemain,Nodesub)
{
if(main==null)
returnnull;
if(main==sub)
r..
分类:
其他好文 时间:
2014-11-28 10:30:24
阅读次数:
157
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
这个题目比较简单,借助容器queue即可完成二叉树的层序遍历。我的C++实现代码如下:
vector > levelOrder(TreeNode *...
分类:
其他好文 时间:
2014-11-28 10:22:22
阅读次数:
206
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
这个简单的问题可以这样解决:利用LeetCode[Tree]: Binary Tree Level...
分类:
其他好文 时间:
2014-11-28 10:15:15
阅读次数:
227
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
分类:
其他好文 时间:
2014-11-28 06:10:40
阅读次数:
259
问题描述:
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it ...
分类:
其他好文 时间:
2014-11-27 23:42:16
阅读次数:
239
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.注意写出鲁棒性的代...
分类:
其他好文 时间:
2014-11-27 23:30:28
阅读次数:
202
题目:Binay Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level...
分类:
其他好文 时间:
2014-11-27 17:56:43
阅读次数:
110