摘要: 题目: 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.Return a deep ... 阅读全文
posted @ 2014-05-14 10:17 ThreeMonkey 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exa... 阅读全文
posted @ 2014-05-14 10:11 ThreeMonkey 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such poss... 阅读全文
posted @ 2014-05-14 10:02 ThreeMonkey 阅读(194) 评论(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-05-13 20:42 ThreeMonkey 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up: Can you solve it without using extr... 阅读全文
posted @ 2014-05-13 20:40 ThreeMonkey 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 题目: 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 nodes' values. ... 阅读全文
posted @ 2014-05-13 20:12 ThreeMonkey 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a binary tree, return thepreordertraversal of its nodes' values. For example: Given binary tree{1,#,2,3}, 1 \ 2 / ... 阅读全文
posted @ 2014-05-13 20:09 ThreeMonkey 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a binary tree, return thepostordertraversal of its nodes' values. For example: Given binary tree{1,#,2,3}, 1 \ 2 / ... 阅读全文
posted @ 2014-05-13 20:04 ThreeMonkey 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 题目: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset. get(key)- Get ... 阅读全文
posted @ 2014-05-13 19:55 ThreeMonkey 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 题目: Sort a linked list using insertion sort.解题思路: 假设 list[1..i]是排好序的,找到第i+1个元素应该插入的位置及其前驱,然后将其插入。代码: /** * Definition for singly-linked list. * str... 阅读全文
posted @ 2014-05-13 19:46 ThreeMonkey 阅读(121) 评论(0) 推荐(0) 编辑