会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
小痘比
博客园
首页
新随笔
联系
订阅
管理
2018年1月15日
[LeetCode]16. 3Sum Closest
摘要: 原题链接:https://leetcode.com/problems/3sum-closest/description/ 我的实现:
阅读全文
posted @ 2018-01-15 22:01 小痘比
阅读(89)
评论(0)
推荐(0)
编辑
[LeetCode]15. 3Sum
摘要: 原题链接:https://leetcode.com/problems/3sum/description/ 意思是对给定的数组找到所有三个数加起来为0的数的下标 我的实现:
阅读全文
posted @ 2018-01-15 22:00 小痘比
阅读(90)
评论(0)
推荐(0)
编辑
[LeetCode]14. Longest Common Prefix
摘要: 原题链接:https://leetcode.com/problems/longest-common-prefix/description/ 我的实现:
阅读全文
posted @ 2018-01-15 21:35 小痘比
阅读(85)
评论(0)
推荐(0)
编辑
[LeetCode]13. Roman to Integer
摘要: 原题链接:https://leetcode.com/problems/roman-to-integer/description/ 和上一题正好相反,将罗马数字变为int,知道罗马数字的规则后很好做 我的实现:
阅读全文
posted @ 2018-01-15 21:12 小痘比
阅读(115)
评论(0)
推荐(0)
编辑
[LeetCode]12. Integer to Roman
摘要: 原题链接:https://leetcode.com/problems/integer-to-roman/description/ 给定数字输出罗马数字 我的实现: 总结:主要就是注意罗马数字的规则
阅读全文
posted @ 2018-01-15 21:09 小痘比
阅读(93)
评论(0)
推荐(0)
编辑
[LeetCode]11. Container With Most Water
摘要: 原题链接:https://leetcode.com/problems/container-with-most-water/description/ 意思是在坐标系x轴每个整数点画垂直于x轴的线,高度由输入给定,然后计算任意两条线与x轴围成的面积(木桶效应,高度为两条中较低的那条)。 我的实现(Two
阅读全文
posted @ 2018-01-15 17:01 小痘比
阅读(143)
评论(0)
推荐(0)
编辑
[LeetCode]10. Regular Expression Matching
摘要: 原题链接:https://leetcode.com/problems/regular-expression-matching/description/ 实现正则表达式中‘.’和 ‘*’的功能; 正则表达式‘.’代表一个任意字符,‘*’代表该符号前字符任意个数,所以‘*’之前肯定是要有一个字符的。 我
阅读全文
posted @ 2018-01-15 16:40 小痘比
阅读(94)
评论(0)
推荐(0)
编辑
[LeetCode]9. Palindrome Number
摘要: 原题链接:https://leetcode.com/problems/palindrome-number/description/ 意思是判断一个数是不是回文数,回文就是正着反着都一样,注意负数不是回文。 题目还有要求不能使用多余空间,即将数字转为字符串再去看是不是回文是不行的。 回文数字的特点就是
阅读全文
posted @ 2018-01-15 16:29 小痘比
阅读(104)
评论(0)
推荐(0)
编辑
[LeetCode]8. String to Integer (atoi)
摘要: 原题链接:https://leetcode.com/problems/string-to-integer-atoi/description/ 意思是把输入的字符串string转为int。然后会有错误输入,要对这些进行处理。具体要求为Requirements for atoi: 我的实现: 总结:仔细
阅读全文
posted @ 2018-01-15 16:15 小痘比
阅读(135)
评论(0)
推荐(0)
编辑
[LeetCode]7. Reverse Integer
摘要: 原题链接:https://leetcode.com/problems/reverse-integer/description/ 意思是对于给定的数字,调换最高位和最低位,次高位和次低位......然后输出。如果调换数位后超过了32位int表达范围就输出0。 我的提交(又不知道从哪位大佬博客看到,以后
阅读全文
posted @ 2018-01-15 16:01 小痘比
阅读(121)
评论(0)
推荐(0)
编辑
[LeetCode]6. ZigZag Conversion
摘要: 原题链接:https://leetcode.com/problems/zigzag-conversion/description/ 意思是给定输入字符串和行数,把字符串字符按照锯齿状排列后,按行从左到右输出目标字符串。 我的实现: 解释:zigzag排列字符是有规律的,我是以从顶点直线向下开始到达最
阅读全文
posted @ 2018-01-15 15:40 小痘比
阅读(160)
评论(0)
推荐(0)
编辑
[LeetCode]5. Longest Palindromic Substring
摘要: 原题链接:https://leetcode.com/problems/longest-palindromic-substring/description/ 题目意思是给定字符串,要求找到最长的回文字符串。回文字符串就是正着读反着读都一样的字符串,如:“ababa”,“abba”这种 怎么样找到回文字
阅读全文
posted @ 2018-01-15 15:20 小痘比
阅读(156)
评论(0)
推荐(0)
编辑
[LeetCode]4. Median of Two Sorted Arrays
摘要: 原题链接:https://leetcode.com/problems/median-of-two-sorted-arrays/description/ 找到两组已排序数列的中间值。时间复杂度要为O(log (m+n)). 我的实现(不记得在哪篇大佬博客看到的方法): 思想:考虑到两个数组的个数总和有
阅读全文
posted @ 2018-01-15 14:57 小痘比
阅读(99)
评论(0)
推荐(0)
编辑
[LeetCode]3. Longest Substring Without Repeating Characters
摘要: 原题链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ 意思是给定字符串,输出无重复字符的最长子串长度 我的实现(Brute Force)生成全部无重复子串,从而得到
阅读全文
posted @ 2018-01-15 11:17 小痘比
阅读(159)
评论(0)
推荐(0)
编辑
[LeetCode]2. Add Two Numbers
摘要: 原题链接:https://leetcode.com/problems/add-two-numbers/description/ 意思是给定两个存在链表中的数,输出和(同样存储在链表中)。 我的实现: 主要是注意进位,结果的保存。不要像我一样这么麻烦地保存结果的,直接在运算时构建结果链表即可。
阅读全文
posted @ 2018-01-15 10:05 小痘比
阅读(114)
评论(0)
推荐(0)
编辑
[LeetCode]1. Two Sum
摘要: 原题链接:https://leetcode.com/problems/two-sum/description/ 意思是给定输入数组和目标数,要求输出数组中两个相加刚好为目标数的元素下标 我的实现(Brute Force): 时间复杂度:O(n2). 空间复杂度:O(1). 怎么样提高算法效率呢
阅读全文
posted @ 2018-01-15 09:49 小痘比
阅读(125)
评论(0)
推荐(0)
编辑
公告