上一页 1 ··· 3 4 5 6 7 8 下一页

2014年12月3日

LRU Cache

摘要: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文

posted @ 2014-12-03 11:37 code#swan 阅读(100) 评论(0) 推荐(0)

Insertion Sort List

摘要: Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNo... 阅读全文

posted @ 2014-12-03 11:36 code#swan 阅读(100) 评论(0) 推荐(0)

Sort List

摘要: Sort a linked list inO(nlogn) time using constant space complexity./** * Definition for singly-linked list. * struct ListNode { * int val; * L... 阅读全文

posted @ 2014-12-03 11:34 code#swan 阅读(123) 评论(0) 推荐(0)

Evaluate Reverse Polish Notation

摘要: Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文

posted @ 2014-12-03 11:33 code#swan 阅读(116) 评论(0) 推荐(0)

Reverse Words in a String

摘要: Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".class Solution: # @param s,... 阅读全文

posted @ 2014-12-03 11:26 code#swan 阅读(76) 评论(0) 推荐(0)

Maximum Product Subarray

摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文

posted @ 2014-12-03 11:23 code#swan 阅读(74) 评论(0) 推荐(0)

Find Minimum in Rotated Sorted Array

摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文

posted @ 2014-12-03 11:22 code#swan 阅读(79) 评论(0) 推荐(0)

Find Minimum in Rotated Sorted Array II

摘要: Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort... 阅读全文

posted @ 2014-12-03 11:21 code#swan 阅读(82) 评论(0) 推荐(0)

Min Stack

摘要: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文

posted @ 2014-12-03 11:20 code#swan 阅读(155) 评论(0) 推荐(0)

Intersection of Two Linked Lists

摘要: Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文

posted @ 2014-12-03 11:18 code#swan 阅读(178) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 下一页

导航