自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

原创 39. Combination Sum-回溯法

Tags: backTracking(回溯法)   http://blog.csdn.net/jarvischu/article/details/16067319              http://www.cnblogs.com/chinazhangjie/archive/2010/10/22/1858410.html            http://blog.csdn.ne

2016-08-29 21:35:39 582

原创 Isomorphic Strings

tags:hash table两种情况下返回false:1)s中一个字符对应t中两个不同的字符。2)t中一个字符对应s中两个不同的字符。其他情况下都返回true。建两个hash表,m1、m2。代码:class Solution {public: bool isIsomorphic(string s, string t) { int size = s.size

2016-08-25 16:21:57 217

原创 Majority Element / Majority Element 2-主要元素

一类找主要元素的题目。最简单最直观的想法就是,统计每个元素出现的个数(可以用map),然后再判断哪些元素是主要元素。时间和空间复杂度都是O(n)。但是,Majority Element 2要求空间复杂度为O(1)。这就没想出来了。网上搜了下,这是一类问题,即找主要元素的问题,采用moore投票法的思想。Majority Element:摩尔投票法 Moore Voting,

2016-08-24 16:35:36 318

原创 3Sum Closest

tags:two pointers解法思想见:http://www.sigmainfy.com/blog/summary-of-ksum-problems.html代码:class Solution {public: int threeSumClosest(vector& nums, int target) { sort(nums.begin(), nums.

2016-08-23 21:59:07 209

原创 307. Range Sum Query - Mutable

Tags--binary indexed tree(二分索引树,树状数组)

2016-08-19 20:31:39 453

原创 binary indexed tree 二分索引树 树状数组

参考:https://www.byvoid.com/blog/binary-index-treehttp://www.cnblogs.com/sixdaycoder/p/4348360.htmlhttp://blog.csdn.net/liangzhaoyang1/article/details/513651921)求CiC[i] = A[i-2^k+1]

2016-08-19 20:07:34 1457

原创 349. Intersection of Two Arrays

Tags- binary search, hash table, two pointers, sort方法一:sort+binary search先对nums1、nums2从小到大排序,然后,对于nums2中不同的元素,我们在nums1中二分搜索,看看是否存在。这里注意,nums2中的元素是排过序的,所以没有必要每个元素都在(0, nums1.size()-1)中二分搜索。比如,num

2016-08-19 15:33:29 284

原创 Russian Doll Envelopes-最长递增子序列

方法:DP+ 二分搜索具体一点说,二分搜索是用在LIS(最长递增子序列)中(LIS见:点击打开链接)。主要思想就是LIS的思想。有O(N*N)和O(NlgN)两种解法。不论是哪种解法,首先都得按照w(宽)值对envelopes进行递增排序。简单直观的O(N*N)的方法。class Solution {public: int maxEnvelopes(vector>& env

2016-08-17 01:12:34 326

原创 131. Palindrome Partitioning

回文分割。DP+dfs。先判断str中任意字串是否是回文,用动态规划方法://construct the pailndrome checking matrix// 1) matrix[i][j] = true; if (i==j) -- only one char// 2) matrix[i][j] = true; if (i==j+1) && s[i]==s[j] -- o

2016-08-16 00:49:37 403

空空如也

空空如也

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

TA关注的人

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