11 2013 档案

[LeetCode] LRU Cache, Solution
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the... 阅读全文

posted @ 2013-11-28 14:56 小刀初试 阅读(160) 评论(0) 推荐(0)

[LeetCode] Binary Tree Preorder Traversal, Solution
摘要:Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3... 阅读全文

posted @ 2013-11-26 13:42 小刀初试 阅读(147) 评论(0) 推荐(0)

[LeetCode] Reorder List, Solution
摘要:Given a singly linked list L: 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. For... 阅读全文

posted @ 2013-11-24 14:31 小刀初试 阅读(161) 评论(0) 推荐(0)

[LeetCode] Linked List Cycle II, Solution
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up:Can you solve it without using extra space? ... 阅读全文

posted @ 2013-11-24 06:11 小刀初试 阅读(162) 评论(0) 推荐(0)

[LeetCode] Linked List Cycle, Solution
摘要:Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? [Thoughts] 设定两个指针,一个每次走一步,一个每次走两步,如果链表... 阅读全文

posted @ 2013-11-21 12:51 小刀初试 阅读(108) 评论(0) 推荐(0)

Design Summary
摘要:Scalable Web Architecture and Distributed System 阅读全文

posted @ 2013-11-21 12:42 小刀初试 阅读(146) 评论(0) 推荐(0)

[LeetCode] WordBreak II, Solution
摘要:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such ... 阅读全文

posted @ 2013-11-21 12:17 小刀初试 阅读(167) 评论(0) 推荐(0)

[LeetCode] Word Break, Solution
摘要:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For ... 阅读全文

posted @ 2013-11-19 14:02 小刀初试 阅读(173) 评论(0) 推荐(0)

[LeetCode] Copy List with Random Pointer, Solution
摘要: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 co... 阅读全文

posted @ 2013-11-18 14:15 小刀初试 阅读(143) 评论(0) 推荐(0)

[LeetCode] Single Number II, Solution
摘要:Given an array of integers, every element appears three times except for one. Find that single one. Note:Your algorithm should have a linear runtime... 阅读全文

posted @ 2013-11-18 07:01 小刀初试 阅读(136) 评论(0) 推荐(0)

[LeetCode] Single Number, Solution
摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime comple... 阅读全文

posted @ 2013-11-14 14:42 小刀初试 阅读(137) 评论(0) 推荐(0)

[LeetCode] Candy, Solution
摘要:There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re... 阅读全文

posted @ 2013-11-14 14:24 小刀初试 阅读(164) 评论(0) 推荐(0)

[LeetCode] Gas Station, Solution
摘要:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs... 阅读全文

posted @ 2013-11-12 13:27 小刀初试 阅读(168) 评论(0) 推荐(0)