- 博客(3)
- 收藏
- 关注
原创 [LeetCode] Python实现 18. 四数之和
使用分组计算把求四个变量化为求2组变量和,实现时间复杂度O(n^2)class Solution: def fourSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[List[int]] """...
2018-08-10 00:13:17 807
原创 [LeetCode] Python实现 3.无重复字符的最长子串
从左向右进行扫描,遇到重复的字符时,从前一个出现该字符的位置的下一个字符开始,重新扫描,直到扫描到最后。class Solution: def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ res = '' ...
2018-08-05 23:59:20 256
原创 [LeetCode] Python实现 2.两数相加
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def addTwoNumbers(self, l1, l2): """...
2018-08-05 23:07:44 147
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人