修行中人
修行中人
全部文章
分类
未归档(1)
题解(8)
归档
标签
去牛客网
登录
/
注册
修行中人
小菜鸟在线编程;欢迎大家宠爱
全部文章
(共9篇)
124. 二叉树中的最大路径和
class Solution: def maxPathSum(self, root: TreeNode) -> int: """ 解决这题的主要思路是分断考虑+递归 最大路径和的取得有三种情况: 1. 当前root结点和左...
dfs
python
二叉树
最大路径和
2020-09-08
0
419
309. 最佳买卖股票时机含冷冻期-Python
参考题解中https://leetcode-cn.com/u/jin-ai-yi/以下是python版本加详细注释,备忘一下。 class Solution: def maxProfit(self, prices: List[int]) -> int: """ ...
python
股票买卖
2020-09-07
1
940
redis缓存穿透与缓存雪崩
1. 缓存穿透原因:缓存穿透是客户端请求了缓存层不存在的key,那么请求就会穿过缓存层,打到持久层DB上。造成的问题:大规模不存在的key请求全部打到底层数据库,造成数据库瘫痪。解决:引入布隆过滤器,持久层数据库中数据映射到布隆过滤器中,未知key请求穿过redis,由布隆过滤器检查key有效性,由...
缓存雪崩
redis
缓存穿透
2020-08-24
2
482
二叉树镜像(python、BFS)
class Solution: # 返回镜像树的根节点, BFS做法 def Mirror(self, root): # write code here nodeQueue = [root] while nodeQueue: ...
2020-04-08
5
924
反转链表,python
class Solution: # 返回ListNode def ReverseList(self, pHead): # write code here if not pHead: return None else: ...
链表,python
2020-04-02
0
504
查找链表中倒数第k个节点
基于python,感觉代码过于冗余,条件判断和while太多,求大佬帮忙优化一下,感谢! class Solution: def FindKthToTail(self, head, k): # write code here # 查看是否为空链表; 查看k值,...
链表,python
2020-04-02
1
584
字符串排序
def sortStr(inStr): res = [0] * len(inStr) helpLs = [] for i, s in enumerate(inStr): if s.isalpha(): helpLs.append(s) ...
2020-03-31
0
576
求base的exponent次方。 保证base和exponent不同时为0
递归代码,和直接循环结果差不多,且空间复杂度更高。 # -*- coding:utf-8 -*- class Solution: def Power(self, base, exponent): # write code here if base == 0: ...
2020-03-29
0
566
删除字符串中出现次数最少的字符
方法很low,本人在不断学习中,用类写的,请大家批评指正,谢谢大佬们。(python3)首先,生成Sol对象的时候,会对字符串中单个字符计数,保存在strDict中,接下来调用delLittleStr方法,删除出现最少的字符,返回新的字符串。 class Sol: def __init__(...
python字符串
2020-03-24
6
907