![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
文章平均质量分 73
EffortForever
一只特立独行的猫。
展开
-
String to Integer (atoi)【易】
String to Integer (atoi)自己实现atoi函数完成字符串转成整数难度:易题目比较容易,但是输入很恶心,各种空格、+、-符号。代码写的比较乱==‘例子:“+123” 123“-123” 123“123” 123“ +123” 123“+123 ” 123“+ 123” 0“ +123 4” 123cl原创 2016-11-26 21:59:21 · 433 阅读 · 0 评论 -
LeetCode Weekly Contest 13-HammingDistance【易】
HammingDistanceThe Hamming distance between two integers is thenumber of positions at which the corresponding bits are different.Given two integers x and y, calculatethe Hamming distance.Note:原创 2016-12-19 09:45:21 · 457 阅读 · 0 评论 -
LeetCode Weekly Contest 13-TotalHamming Distance【中】
TotalHamming DistanceThe Hamming distance between two integers is thenumber of positions at which the corresponding bits are different.Now your job is to find the totalHamming distance between a原创 2016-12-19 09:49:41 · 445 阅读 · 0 评论 -
Palindrome Number【易】
Palindrome Number对称整数,给定一个整数判断它是不是一个对称整数即正读还是反读是一样的。难度:易例子:1233211234554321 思路:可以将这个整数翻转看翻转后的整数是否和翻转前相同直接上代码:class Solution {public: bool isPalindrome(int x) { int rever原创 2016-11-26 22:06:00 · 420 阅读 · 0 评论 -
Reverse Integer【易】
Reverse Integer翻转一个整数难度:易例子:Example1: x = 123, return 321Example2: x = -123, return -321 没甚麽好说的,直接上代码;class Solution {public: int reverse(int x) { int i, j, k = 0;原创 2016-11-26 21:49:43 · 321 阅读 · 0 评论 -
Longest Palindromic Substring【中】
Longest Palindromic Substring给定一个字符串,寻找最长对称子串。难度:中等例子:"babad"aba为最长的对称子串 这道题同样可以暴力枚举,时间复杂度为O(n^3),子串的数量为n^2个,在对每个子串判断是否对称O(n)。同样这种解法同样丧失了这道题的意义。下面介绍一个在O(n^2)时间复杂度内解决。其实没必要枚举每种可能的子串,只需要原创 2016-11-26 21:41:06 · 429 阅读 · 0 评论 -
Regular Expression Matching【难】
Regular Expression MatchingLeetcode真的是一个不错的网站,全世界的人都在上面刷题,上面的题还是挺好的。现将我在上面做过的题写成解题报告,既是一种分享也是一个记录防止日后自己在转过头来看自己的解法又看不懂了。好了废话不多说Regular Expression Matching题目大致意思是实现一个正则表达式支持’.’和’*’两种特殊符号,其匹配规则如下:原创 2016-11-26 17:14:16 · 704 阅读 · 0 评论 -
Longest Substring Without Repeating Characters 最长不重复子串【中】
Longest Substring Without Repeating Characters给定一个字符串,寻找最长不重复子串长度。难度:中等比如:"abcabcbb",结果是"abc" 长度为3“bbbbb” 结果为b,长度为1"pwwkew" 结果为wke,长度为3此题很容易想到O(n^3)的解法即枚举所有子串O(n^2),然后判断每个子串是否有重复的字符O(n),原创 2016-11-26 21:19:57 · 442 阅读 · 0 评论 -
Container With Most Water【中】
Container With Most Water题目意思:给定一个非负的整数数组,a1,a2,a3,a4.....,an,其中每一个数都代表一个坐标为(i,ai)的点。现在每个点垂直与x轴相交,交点为(i,0),这样就构成了n条垂直线。现在从n条线里面挑出两条,然后和x轴围城了一个矩形问围成的最大的矩形的面积是多少。难度:中等此题很容易想到O(n^2)的解法,围成的所有可能的矩形数量原创 2016-12-01 23:35:59 · 465 阅读 · 0 评论 -
LeetCode Weekly Contest 13-Matchsticks to Square【中】
Matchsticks to SquareRememberthe story of Little Match Girl? By now, you know exactly what matchsticks thelittle match girl has, please find out a way you can make one square by usingup all those ma原创 2016-12-19 09:57:27 · 695 阅读 · 0 评论