随笔分类 -  LeetCode刷题

摘要:恢复内容开始 # coding:utf-8 """ Name : LeetCode28.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/7 17:17 Desc:实现 strStr() """ class Solution: d 阅读全文
posted @ 2021-02-07 17:22 qilibin 阅读(86) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : 剑指offer58.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/7 14:14 Desc: 左旋字符串 """ class Solution: def reverseLef 阅读全文
posted @ 2021-02-07 17:21 qilibin 阅读(51) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : 剑指offer05.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/7 9:56 Desc: 替换字符串空格 """ # python 字符串不可原地修改 因此先将字符串转换为 阅读全文
posted @ 2021-02-07 10:33 qilibin 阅读(45) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : NO541.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/7 9:28 Desc: 翻转字符串2 """ #解题思路 # 把遍历的步长改为 2*k 即可 将 i:i + k 阅读全文
posted @ 2021-02-07 09:55 qilibin 阅读(86) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : NO344.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/6 23:21 Desc: 反转字符串 """ from typing import List # 解题思路 # 双 阅读全文
posted @ 2021-02-06 23:30 qilibin 阅读(148) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : LeetCode18.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/6 21:30 Desc: 四数之和 扩展到 n数之和 """ from typing import Li 阅读全文
posted @ 2021-02-06 22:34 qilibin 阅读(105) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : LeetCode383.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/6 9:32 Desc:赎金信 """ # 解题思路 和四数相加思路类似 # 1分为两部分 将两个字符串 阅读全文
posted @ 2021-02-06 10:08 qilibin 阅读(62) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : LeetCode454.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/5 17:21 Desc: 四数相加 """ import collections from typin 阅读全文
posted @ 2021-02-05 21:32 qilibin 阅读(112) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : LeetCode1.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/5 15:26 Desc: 两数之和 """ from typing import List #解题思路1 阅读全文
posted @ 2021-02-05 16:34 qilibin 阅读(103) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : LeetCode202.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/5 10:49 Desc: 快乐数 """ #「当我们遇到了要快速判断一个元素是否出现集合里的时候,就要 阅读全文
posted @ 2021-02-05 15:16 qilibin 阅读(106) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : LeetCode349.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/5 10:19 Desc: 两个数组的交集 """ from typing import List #解 阅读全文
posted @ 2021-02-05 10:46 qilibin 阅读(61) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : NO242.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/5 8:08 Desc: 有效字母异位词 """ #解题思路 #有效字母异位词的条件有以下几个 #1 两个字符串长度 阅读全文
posted @ 2021-02-05 08:53 qilibin 阅读(140) 评论(0) 推荐(0)
摘要:# coding:utf-8 """ Name : NO142.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/4 10:40 Desc: """ #解题思路 # 暴力解法 遍历所有的节点 将被遍历过的节点存储在一个临时变量tm 阅读全文
posted @ 2021-02-04 22:06 qilibin 阅读(91) 评论(0) 推荐(0)
摘要:第一种方法:双指针法 # coding:utf-8 """ Name : NO206.py Author : qlb Contect : 17801044486@163.com Time : 2021/2/3 22:11 Desc: """ # Definition for singly-linke 阅读全文
posted @ 2021-02-03 23:13 qilibin 阅读(108) 评论(0) 推荐(0)
摘要:设计链表的实现。您可以选择使用单链表或双链表。单链表中的节点应该具有两个属性:val 和 next。val 是当前节点的值,next 是指向下一个节点的指针/引用。如果要使用双向链表,则还需要一个属性 prev 以指示链表中的上一个节点。假设链表中的所有节点都是 0-index 的。 在链表类中实现 阅读全文
posted @ 2021-02-03 21:53 qilibin 阅读(99) 评论(0) 推荐(0)