Problem Description:Given a binary tree, return thepostordertraversal of its nodes' valuesSolution: 1 public List postorderTraversal(TreeNode root) { ...
分类:
其他好文 时间:
2014-07-07 16:45:23
阅读次数:
177
Problem Description:Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the no...
分类:
其他好文 时间:
2014-07-07 16:41:56
阅读次数:
141
Problem Description:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.ge...
分类:
其他好文 时间:
2014-07-07 16:41:12
阅读次数:
237
Problem Description:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Solution: ...
分类:
其他好文 时间:
2014-07-07 16:39:19
阅读次数:
163
Problem Description:Given a binary tree, return thepreordertraversal of its nodes' values.Solution: 1 public List preorderTraversal(TreeNode root)...
分类:
其他好文 时间:
2014-07-07 16:34:34
阅读次数:
208
Problem Description:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to...
分类:
其他好文 时间:
2014-07-07 16:22:28
阅读次数:
129
Problem Description:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in th...
分类:
其他好文 时间:
2014-07-07 16:20:26
阅读次数:
216
Problem Description:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null...
分类:
其他好文 时间:
2014-07-07 16:19:01
阅读次数:
188
Problem Description:Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.Solution: 1 public UndirectedGraph...
分类:
其他好文 时间:
2014-07-07 16:11:57
阅读次数:
192
Problem Description:Given an array of integers, every element appearsthreetimes except for one. Find that single one.Solution:1 Arrays.sort(A...
分类:
其他好文 时间:
2014-07-07 16:10:04
阅读次数:
174