- 博客(78)
- 收藏
- 关注
原创 leetcode-Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You may
2014-07-16 21:47:33 521
原创 leetcode-Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on
2014-07-16 11:40:27 422
原创 leetcode-Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
2014-07-16 11:04:00 405
原创 leetcode-Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy t
2014-07-15 17:52:21 319
原创 leetcode-Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu
2014-07-14 16:43:03 385
原创 leetcode-Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from
2014-07-13 17:35:23 330
原创 leetcode-Gas Station
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 cost[i] of gas to travel from station i to
2014-07-13 16:14:07 424
原创 leetcode-candy
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 requirements:Each child must have at least on
2014-07-11 21:57:50 466
原创 leetcode-Reorder List
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 example,Given {1,2,3,4}, reorder it to
2014-07-11 19:32:01 374
原创 leetcode-Single Number II
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 complexity. Could you implement it without usi
2014-07-11 10:49:33 340
原创 leetcode-single number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ext
2014-07-10 20:45:58 335
原创 leetcode-Linked List Cycle II
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?思路:双指针判断是否you
2014-07-10 17:47:03 407
原创 leetcode-Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:双指针,一个指针一次走两步,
2014-07-10 16:21:50 394
原创 leetcode-sort list
Sort a linked list in O(n log n) time using constant space complexity.思路:gui
2014-07-09 11:10:32 329
原创 ubuntu 错误:E: Some index files failed to download. They have been ignored, or old ones used instead.
E: Some index files failed to download. They have been ignored, or old ones used instead.
2014-07-08 17:01:03 6825 1
原创 leetcode-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".Clarification:What constitutes a word?A sequence of non-sp
2014-07-03 17:02:24 477
原创 leetcode-Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of
2014-07-02 10:50:56 392
原创 leetcode-Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"思路:字符串的处理
2014-07-01 11:11:04 438
原创 leetcode-Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?思路:递归,f(n)=
2014-06-25 20:18:06 440
原创 leetcode-Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,
2014-06-25 11:47:55 361
原创 leetcode-Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the
2014-06-24 20:42:58 317
原创 leetcode-Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-
2014-06-24 14:26:45 311
原创 leetcode-Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.思路:双指针
2014-06-24 11:44:44 459
原创 leetcode-Maximal Rectangle
http://blog.csdn.net/doc_sgl/article/details/11832965
2014-06-24 11:13:05 364
原创 leetcode-Largest Rectangle in Histogram
先用baolihttp://blog.csdn.net/doc_sgl/article/details/11805519
2014-06-24 10:55:38 353
原创 leetcode-Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路:与处理合并链表类似,两个zhizhen
2014-06-18 11:42:32 406
原创 leetcode-Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路:链表的基本操作,ji
2014-06-18 10:55:25 347
原创 leetcode-Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.思路:依然是don
2014-06-17 21:51:17 387
原创 leetcode-Unique Paths II
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the
2014-06-17 17:32:09 360
原创 leetcode-Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the
2014-06-17 16:55:19 370
原创 leetcode-rotate list
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.思路:双指针
2014-06-17 10:50:40 365
原创 leetcode-insert interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E
2014-06-17 10:17:42 363
原创 leetcode-Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is
2014-06-16 17:33:32 359
原创 leetcode-Merge Intervals
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].
2014-06-14 15:24:26 434
原创 jump game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i
2014-06-11 22:29:45 322
原创 leetcode-Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha
2014-06-11 20:54:37 426
原创 leetcode-Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:要求空间复杂度为o(
2014-06-09 15:56:13 354
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人