摘要: 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... 阅读全文
posted @ 2014-06-29 14:36 HaruHaru 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more diction... 阅读全文
posted @ 2014-06-29 14:03 HaruHaru 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Ret... 阅读全文
posted @ 2014-06-29 14:01 HaruHaru 阅读(173) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Solution: 1 public bo... 阅读全文
posted @ 2014-06-29 14:00 HaruHaru 阅读(118) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without u... 阅读全文
posted @ 2014-06-29 13:58 HaruHaru 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2014-06-29 13:57 HaruHaru 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Given a binary tree, return thepreordertraversal of its nodes' values.Solution: 1 public List preorderTraversal(TreeNode root)... 阅读全文
posted @ 2014-06-29 13:56 HaruHaru 阅读(108) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Given a binary tree, return thepostordertraversal of its nodes' valuesSolution: 1 public List postorderTraversal(TreeNode root) { ... 阅读全文
posted @ 2014-06-29 13:54 HaruHaru 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.ge... 阅读全文
posted @ 2014-06-29 13:53 HaruHaru 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Problem Description:Sort a linked list using insertion sort.Solution: 1 public class Solution { 2 public ListNode insertionSortList(ListNode head)... 阅读全文
posted @ 2014-06-29 13:51 HaruHaru 阅读(127) 评论(0) 推荐(0) 编辑