自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

甜橙的专栏

漫长的修炼之路!

  • 博客(19)
  • 收藏
  • 关注

原创 LeetCode45. Jump Game II

题意: 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.Your goal is to

2016-12-11 09:33:04 325

原创 LeetCode41. First Missing Positive

题意: Given an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant spa

2016-12-10 20:35:48 265

原创 LeetCode37. Sudoku Solver

题意:解9*9数独做法:回溯 对每一个还没填充的格子,尝试1~9这9个数字,如果是合法的,则继续填充下一个格子,否则回溯。 判断合法:只需要判断对应行、对应列、对应3*3,有没有矛盾。设未被填充的格子个数为n,那么时间复杂度大约为O(9n+1)=O(9n)O(9^{n+1})=O(9^n) 在leetcode上用时76ms,本题在leetcode上有0ms的解法, 2ms解法 0ms解法c

2016-12-10 14:50:23 971

原创 LeetCode31. Next Permutation

题意: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest p

2016-12-09 17:08:30 259

原创 LeetCode30. Substring with Concatenation of All Words

题意: You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once a

2016-12-09 16:24:32 505

原创 作业-NP完全问题证明-8.23

题目: 在节点互不相交的路径(NODE-DISJOINT PATH)问题中,输入是一个无向图。该图的一些节点具有特殊标记:节点s1,s2,…,sks_1,s_2,\ldots,s_k 被标记为“出发点”,另一些相同数量的节点t1,t2,…,tkt_1,t_2,\ldots,t_k 被标记为“目的地”。目标是对所有的i=1,2,…,ki=1,2,\ldots,k ,求由sis_i 到tit_i

2016-12-01 14:23:57 2353 1

原创 LeetCode10. Regular Expression Matching

该题和wildcard matching类似,但是*意义改变 题意:Implement regular expression matching with support for ‘.’ and ‘*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. The

2016-11-16 12:10:24 187

原创 LeetCode44. Wildcard Matching

题意:Implement wildcard pattern matching with support for ‘?’ and ‘*’. ‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence). The matching shou

2016-11-16 00:10:46 225

原创 LeetCode85. Maximal Rectangle

题意:Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1

2016-11-15 16:52:44 228

原创 LeetCode84. Largest Rectangle in Histogram

题目:Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. For example,Given heights = [2,1,5,6,2

2016-11-15 14:12:42 196

原创 LeetCode240. Search a 2D Matrix II二分查找+分治法

题意:一个矩阵,每一行都是升序,每一列都是升序。快速判断该矩阵是否有某个值。我起初是这样做的,但是超时了。class Solution {public: bool searchMatrix(vector<vector<int>>& matrix, int target) { if(matrix.empty()||matrix[0].empty()) return false

2016-10-13 01:10:41 614

原创 LeetCode218. The Skyline Problem分治法

题意:轮廓问题,不好描述。首先怎么分:不停对半分停止条件1:为空时,直接返回空停止条件2:大小为1时,直接返回左上角点和右下角点。那么怎么合并?维护两个变量:l,r l为左半部分当前位置,r为右半部分当前位置维护两个变量:h1,h2 h1表示左半部分当前位置高度,h2表示右半部分档期位置高度如果当前位置左半部分横坐标更小,就更新h1,从左半部分选元素;如果当前位置右半部分横坐标更小,

2016-10-12 12:18:59 2688

原创 LeetCode215. Kth Largest Element in an Array分治法

题意:找出无序序列里第k大的元素刚开始我是这样想的:选取序列第0个元素,判断有多少元素比它大、比它小、和它相等,然后缩小问题规模。然后做完之后,leetcode出现memory limit,占用空间过大,因为这样做选取的元素不定,可能每次缩小问题规模的速度太小,导致每次递归次数多,且每步递归开空间存新的序列的空间花费过大。后来我进行修改,不再选取序列第0个元素,而是找出序列最小和最大的元素,求其平均

2016-10-12 11:50:27 697

原创 LeetCode169. Majority Element分治法

题意:求一个序列中出现次数多于一半的元素。 方法很多,可以排序、哈希表、分治等等。

2016-09-21 00:07:18 1771 2

原创 LeetCode53. Maximum Subarray 动态规划和分治法

题意:在一个数组中找到一个和最大的子数组。 有两种方法:动态规划DP分治法

2016-09-20 23:26:36 3293

原创 LeetCode23. Merge k Sorted Lists分治法

题意:将k个有序链表归并为1个有序链表。

2016-09-20 18:56:48 605

原创 LeetCode4. Median of Two Sorted Arrays分治法

问题:求两个以排序序列的中位数。 为了更好的运用分治,将问题转化为求第k小的数。 转化后:两个长度分别为m,n的有序序列,如果m+n为偶数,求第(m+n)/2小的数和第(m+n)/2+1小的数的平均数;否则求第(m+n)/2+1小的数。

2016-09-20 09:33:17 552

原创 LeetCode 5. Longest Palindromic Substring---Manacher's Algorithm

枚举奇偶类型的中心,然后从中心向两边扩展的方法是复杂度是O(n*n),复杂度比较高。 实际上有一种O(n)的解法—Manacher’s Algorithm

2016-09-17 00:47:35 313

原创 LeetCode 1~10(除Hard外)

题号:1,2,3,5,6,7,8,9

2016-09-05 16:09:23 489 5

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除