aiheshan

有多自律,才能有多自由

导航

2016年8月13日 #

leetcode 8. String to Integer (atoi)

摘要: https://leetcode.com/problems/string-to-integer-atoi/ 题目:将字符串转换为整数。 规则: 1. 输入的字符串前可以有多个空格; 2.遇到'-'或者 '+'或者数字字符开始,为连续的多个数字字符。即遇到其他字符结束; 3. 多个连续数字字符后可以有 阅读全文

posted @ 2016-08-13 22:08 aiheshan 阅读(182) 评论(0) 推荐(0) 编辑

leetcode 7. Reverse Integer

摘要: https://leetcode.com/problems/reverse-integer/ 题目:反转数字。 例如: 输入 -321 输出 -123 思路:题目比较简单,主要是主要32位数字溢出的情况。当反正后数字溢出则输出0. 这里用long型记录反转后的数字,然后强制转换为int型,如果转换后 阅读全文

posted @ 2016-08-13 21:05 aiheshan 阅读(181) 评论(0) 推荐(0) 编辑

leetcode 4. Median of Two Sorted Arrays

摘要: https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median o 阅读全文

posted @ 2016-08-13 20:42 aiheshan 阅读(212) 评论(0) 推荐(0) 编辑

leetcode 5. Longest Palindromic Substring

摘要: https://leetcode.com/problems/longest-palindromic-substring/ 题目:求字符串最长回文串。 第一种思路:以每一个字符为回文串中间的字符时,最长的回文串。考虑回文串字符个数为奇数,偶数的2种情况。 x--,j++ 的向两边扩展,判断最长的回文串 阅读全文

posted @ 2016-08-13 20:41 aiheshan 阅读(186) 评论(0) 推荐(0) 编辑

leetcode 6. ZigZag Conversion

摘要: https://leetcode.com/problems/zigzag-conversion/ 题目: 将字符串转化成zigzag模式。 例如 "abcdefghijkmlnpq" 当为4行,zigzag模式为: 思路:以题目中当行为4的为例,将字符串"abcdefghijkmlnpq" 首先转换 阅读全文

posted @ 2016-08-13 20:39 aiheshan 阅读(292) 评论(0) 推荐(0) 编辑