自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Pilgrim

希望某一天跪在那片向往的圣地,满含热泪,亲吻大地,将那之前所经历的种种痛苦,笑着说出来......

  • 博客(11)
  • 资源 (1)
  • 收藏
  • 关注

原创 *LeetCode 89. Gray Code 规律题

https://leetcode.com/problems/gray-code/这种很优美的东西 首先还是写几个例子然后看看规律吧暴力解法:容易错的地方时,intToString的二进制写法, 必须带上位数nconst int SIZE = 1001;class Solution {public: string intToString( int num, in

2016-02-28 02:08:11 388

原创 **LeetCode 84. Largest Rectangle in Histogram

https://leetcode.com/problems/largest-rectangle-in-histogram/O(2n)  至少做过两次,一次是清华的机考准备的时候,一次是ACM的时候,现在仍然想了挺久没搞定,,,,其实问题就是找一个StartIdx 和EndIdx 看两个idx之间的面积。关键点在于:考虑“峰”的面积,并且两边不去计算。。。具体看这里的详解:h

2016-02-27 22:08:31 356

原创 *LeetCode 33. Search in Rotated Sorted Array 二分 值得一练

https://leetcode.com/problems/search-in-rotated-sorted-array/首先二分找pivot 然后判断target可能在pivot之前还是之后,然后在可能的范围继续二分class Solution {public: int search(vector& nums, int target) { if( n

2016-02-27 17:35:44 295

原创 LeetCode 82. Remove Duplicates from Sorted List II 链表 & 83

https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/这种题,还是写个头结点把,写头结点会更顺,很多细节都不用考虑了,然后记得最后return的时候把返回值删除#include #include #include #include #include #include #include

2016-02-27 16:58:34 379

原创 *LeetCode 79. Word Search DFS

https://leetcode.com/problems/word-search/#include #include #include #include #include #include using namespace std;const int SIZE = 129;class Solution {public: bool exis

2016-02-26 20:39:22 375

原创 LeetCode 34. Search for a Range

https://leetcode.com/problems/search-for-a-range/二分即可#include #include #include #include #include #include #include using namespace std;class Solution {public: vector searchRa

2016-02-15 22:33:40 486

原创 **LeetCode 76. Minimum Window Substring

https://leetcode.com/problems/minimum-window-substring/注意跟Leetcode 30的不同,由于这个题目,答案里面可以是有冗余所以涉及到很多细节答案可能是这样的,某一个字母出现的次数比t中该字母出现的次数多,所以在得到一个解时,再缩短解至最短还可以做个优化,就hash数组代替map#include #include

2016-02-15 21:56:31 419

原创 **LeetCode 30. Substring with Concatenation of All Words

https://leetcode.com/problems/substring-with-concatenation-of-all-words/滑动窗口法。解析看这里:http://www.2cto.com/kf/201406/311648.html算法时间复杂度为O(n*k))n是字符串的长度,k是单词的长度#include #include

2016-02-12 23:51:28 407

原创 *LeetCode 75. Sort Colors

https://leetcode.com/problems/sort-colors/取值有限的数组的排序都是可以这样用O(n)完成的class Solution {public: void sortColors(vector& nums) { int cnt0=0,cnt1=0,cnt2=0; for(int i=0; i<nums.size();

2016-02-09 14:52:12 359

原创 LeetCode 74. Search a 2D Matrix 二分法

二分法搜索矩阵,只要把矩阵看成一维即可https://leetcode.com/problems/search-a-2d-matrix/class Solution {public: bool searchMatrix(vector >& matrix, int target) { if(matrix.size() == 0) return false;

2016-02-07 15:23:34 328

原创 LeetCode 73. Set Matrix Zeroes

https://leetcode.com/problems/set-matrix-zeroes/没什么意思的一道题,,暴力class Solution {public: void setZeroes(vector >& matrix) { if(matrix.size() == 0)return; int flag = 0;

2016-02-05 23:35:55 278

演示数据结构的算法过程

帮助数据结构学习,用flash动画生动的演示数据结构的算法过程

2014-01-29

空空如也

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

TA关注的人

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