![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
crazy-bean
这个作者很懒,什么都没留下…
展开
-
3. Longest Substring Without Repeating Characters
关于答案中的三种解法 Approach 1 Brute Force 嵌套循环三次,时间复杂度高 Approach 2 Sliding Window 使用了HashSet,但是在最坏的情况下,时间复杂度O(2n) Approach 3 Sliding Window Optimized 是用了HashMap,通过键值对查找对第二种方法进行优化,减少了时间复杂度 Collection转载 2018-01-23 17:23:04 · 103 阅读 · 0 评论 -
2. Add Two Numbers
// 无小数 / 精确除 % 取余注意:给 l3 添加新节点 l3.next = ListNode(XXX)You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse...原创 2018-02-14 18:20:53 · 99 阅读 · 0 评论 -
14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.自己的解决方案class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] ...转载 2018-03-07 23:04:40 · 100 阅读 · 0 评论 -
13. Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999. I - 1 , V - 5 , X - 10 , L - 50 , C - 100 , D - 500 , M -1000每次跟前面的数字比较,如果小于等于前面的数字,我们先加上当...转载 2018-03-07 23:18:10 · 306 阅读 · 0 评论 -
12. Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999. I - 1 , V - 5 , X - 10 , L - 50 , C - 100 , D - 500 , M -1000注意特殊数字的处理<4 直接叠加,= 4此位置+后面...原创 2018-03-07 23:26:20 · 157 阅读 · 0 评论 -
11. Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two ...原创 2018-03-07 23:34:02 · 116 阅读 · 0 评论 -
6. ZigZag Conversion
特殊情况: numRows = 1 or numRows>len(s) - 不会有字符串变形,直接返回字符串当index == 0 到达第一行位置,开始 +1当index到达末尾位置,也就是最后一行,开始-1def convert(self, s, numRows): """ :type s: str :type numRows: int ...转载 2018-03-05 23:10:27 · 105 阅读 · 0 评论