- 博客(13)
- 收藏
- 关注
原创 455. Assign Cookies
题目Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size
2017-01-07 21:24:39
203
原创 Leetcode 24. Swap Nodes in Pairs 分治
题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant
2016-11-23 17:37:02
210
原创 392. Is Subsequence
题目Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000)
2016-11-23 16:28:20
207
原创 算法概论 8.22
a,对图G每个节点用DFS加上分支记录方法,如果发现有边指向分支已经到达过的点,则将该边删除。最后就能得到一个DAG,删除的边的集合则为E`。每个节点要运算的复杂度为O(n),对所有的n个节点进行操作,可知这个算法是O(n^2)的复杂度,这个算法是我随便说的,可能有更好的方法,但是证明了存在多项式时间的算法,所以FAS是NP问题。 b,图G的每一条边都会至少在G~中生成一个长度为
2016-11-20 00:45:55
283
原创 leetcode 413. Arithmetic Slices [medium]
题目:A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmeti
2016-11-07 16:12:22
222
原创 leetcode 303. Range Sum Query - Immutable 【easy】
题目:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) ->
2016-10-25 17:19:03
391
1
原创 Leetcode 310. Minimum Height Trees【medium】
题目:For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are call
2016-10-04 11:16:54
335
原创 LeetCode 332. Reconstruct Itinerary【medium】
原题:Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JF
2016-10-02 16:42:46
353
翻译 LeetCode 23. Merge k Sorted Lists 【hard】
原题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.题解: ListNode* merge2Lists(ListNode* l1, ListNode* l2){ if(l1!=nullptr && l2!=null
2016-09-22 17:24:02
343
原创 LeetCode 312. Burst Balloons 【hard】
原题:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you wil
2016-09-10 22:42:16
392
原创 LeetCode 169. Majority Element
原题:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority
2016-09-10 15:33:40
211
原创 3. Longest Substring Without Repeating Characters
原题:Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the an
2016-09-06 20:55:37
187
原创 2. Add Two Numbers解题思路
原题:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as
2016-09-06 18:34:21
444
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人