自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(8)
  • 收藏
  • 关注

原创 LeetcodeHot100_004.寻找两个正序数组的中位数

感觉是排序+查找的结合体。但是由于是在路上写的,没看见题目中要求的时间复杂度,直接使用了python的列表sort了一下。还是得掌握一下两个数组合并排序的算法。暴力版本:时间复杂度o(m+n),空间复杂度o(m+n)class Solution(object): def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[

2021-11-28 15:41:44 204

原创 LeetcodeHot100_003.无重复字符的最长子串

又是查找,看了标签,显示:哈希表、滑动窗口打算使用python切片+列表实现class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ # 每一轮循环固定最大窗口,不断更新,最后输出 windows = [0] for i in range(len(s))

2021-11-26 17:38:22 113

原创 力扣上手拦路虎之python字符串

Python字符串|菜鸟教程使用[:]截取字符串中的一部分

2021-11-26 16:22:34 533

原创 LeetcodeHot100_002.两数相加

有bug版本:class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ l3 = ListNode() # 相加 if (not l1 and not l2): ret

2021-11-26 16:08:00 487

原创 力扣上手拦路虎之python链表

Python链表操作(实现)好像把链表放到Python里面就不知道怎么操作了其实就是把基础操作封装起来

2021-11-26 15:50:29 629

原创 LeetcodeHot100_001.两数之和

残暴解法:o(n²)class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] tips: 1.从第一个整数开始,逐个配对 2.成功便输出,失败便下一个 """ for i in r

2021-11-25 20:22:39 198

原创 力扣上手拦路虎之列表输出

class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """需要关注输出的数据格式为list对于def而言,需要有return作为输出,而非print否则例题输出为null而想要将列表作为输出,直接return[i,j]即可..

2021-11-25 19:42:13 164

原创 力扣上手拦路虎之python的类

1. 两数之和class Solution(object): def twoSum(self, nums, target): ''' :type nums: List[int] :type target: int :rtype: List[int] '''使用类的时候需要进行初始化,否则会报错:TypeError: twoSum () missing 1 required positional argument: 't

2021-11-25 17:47:02 217

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除