会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Ry_Chen
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
12
13
14
15
16
2015年9月11日
[LeetCode]题解(python):008-String to Integer (atoi)
摘要: 题目来源:https://leetcode.com/problems/string-to-integer-atoi/题意分析: 这道题也是简单题,题目意思是要将字符串转化成int。比如‘123’转成123.题目思路: 由于有一些其他的输入直接用int()函数肯定是不可以的。比如说‘123b’用int...
阅读全文
posted @ 2015-09-11 18:09 Ry_Chen
阅读(594)
评论(0)
推荐(0)
2015年9月10日
[LeetCode]题解(python):007-Reverse Integer
摘要: 题目来源:https://leetcode.com/problems/reverse-integer/题意分析: 这道题目很简单,就是将一个数反转,123变321,-123变321.题目思路: 这题目很简单,先把数字求绝对值x,然后x%10取最后一位,然后ans = ans*10 + x%10,加上...
阅读全文
posted @ 2015-09-10 18:42 Ry_Chen
阅读(1364)
评论(0)
推荐(0)
[LeetCode]题解(python):006-ZigZag Conversion
摘要: 题目来源:https://leetcode.com/problems/zigzag-conversion/题意分析: 这道题目是字符串处理的题目。输入一个字符串和一个数字,将字符串填入倒Z形输入字符串,然后按照列读取字符,得到一个新的字符,输出这个字符。例如:字符串"PAYPALISHIRING",...
阅读全文
posted @ 2015-09-10 17:24 Ry_Chen
阅读(1500)
评论(1)
推荐(0)
[LeetCode]题解:005-Longest Palindromic Substring优化
摘要: 题目来源和题意分析: 详情请看我的博客:http://www.cnblogs.com/chruny/p/4791078.html题目思路: 我上一篇博客解决这个问题的时间复杂度是最坏情况是(O(n^2))。但是昨天我网上看了别人的做法,其中有一个Manacher算法,其算法复杂度是(O(n))。所以...
阅读全文
posted @ 2015-09-10 14:07 Ry_Chen
阅读(866)
评论(0)
推荐(0)
2015年9月8日
[LeetCode]题解(python):005-Longest Palindromic Substring
摘要: 题目来源:https://leetcode.com/problems/longest-palindromic-substring/题意分析: 这道题目是输入一段不超过1000的字符串,输出最长的回文子字符串,输入的字符串有一个唯一的最长回文子字符串(个人觉得这个没什么用,还限制了一些输入,比如长度为...
阅读全文
posted @ 2015-09-08 11:24 Ry_Chen
阅读(2589)
评论(0)
推荐(1)
2015年9月7日
[LeetCode]题解(python):004-Median of Two Sorted Arrays
摘要: 题目来源:https://leetcode.com/problems/median-of-two-sorted-arrays/题意分析: 这道题目是输入两个已经排好序的数组(长度为m,n),将这两个数组整合成一个数组,输出新数组的中位数。要求时间复杂度是(log(m + n)。比如如果输入[1,2,...
阅读全文
posted @ 2015-09-07 17:21 Ry_Chen
阅读(1914)
评论(1)
推荐(1)
[LeetCode]题解(python):003-Longest Substring Without Repeating Characters
摘要: 题目来源:https://leetcode.com/problems/longest-substring-without-repeating-characters/题意分析: 题目是要求出最长的不重复子字符串的长度。比如字符串abcabcbb,得到的最长无重复子字符串就是abc,bca或者cab,那...
阅读全文
posted @ 2015-09-07 16:00 Ry_Chen
阅读(1338)
评论(0)
推荐(0)
[LeetCode]题解(python):002-Add Two Numbers
摘要: 题目来源:https://leetcode.com/problems/add-two-numbers/题意分析: 这道题目是要将两个单链条相加。输出得到的新链条。题目思路: 不难发现,其实题目就是要我们模拟加法的实现。那么,我们就直接从低位(链条第一位)开始,同位相加,满10就往高位+1。代码(py...
阅读全文
posted @ 2015-09-07 15:39 Ry_Chen
阅读(1097)
评论(0)
推荐(0)
[LeetCode]题解(python):001-Two-Sum
摘要: 题目来源:https://leetcode.com/problems/two-sum/题意分析: 这道题目是输入一个数组和target,要在一个数组中找到两个数字,其和为target,从小到大输出数组中两个数字的位置。题目中假设有且仅有一个答案。题目思路: 如果直接暴力解决,时间复杂度为(O(n^2...
阅读全文
posted @ 2015-09-07 14:37 Ry_Chen
阅读(5283)
评论(0)
推荐(1)
上一页
1
···
12
13
14
15
16
公告