什么鬼?!
什么鬼?!
全部文章
分类
题解(11)
归档
标签
去牛客网
登录
/
注册
什么鬼?!的博客
全部文章
(共10篇)
题解 | #数组中出现次数超过一半的数字#
#统计就用counter。 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 @param numbers int整型一维数组 @return int整型 from collections import Counter class Solution: def More...
Python3
2021-11-27
0
248
题解 | #最长回文子串#
代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 @param A string字符串 @return int整型 class Solution: def getLongestPalindrome(self , A: str) -> int: # write co...
Python3
2021-11-27
3
335
题解 | #最长公共子串#
代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 longest common substring @param str1 string字符串 the string @param str2 string字符串 the string @return string字符串 动态...
Python3
2021-11-25
0
482
题解 | #按之字形顺序打印二叉树#
class TreeNode: def init(self, x): self.val = x self.left = None self.right = None 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 @param pRoot TreeNode类 @ret...
Python3
2021-11-25
0
298
题解 | #有效括号序列#
FILO 用栈匹配,事半功倍。>.< 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 @param s string字符串 @return bool布尔型 class Solution: def isValid(self , s: str) -> ...
Python3
2021-11-25
0
298
题解 | #跳台阶#
递归可能超时,所以使用循环来做。 思想和递归相同。从3开始往后计算跳法。 -- coding:utf-8 -- class Solution: def jumpFloor(self, number): # write code here # write code here t1, t2, total...
Python3
2021-11-24
0
184
题解 | #寻找第K大#
-- coding:utf-8 -- class Solution: def findKth(self, a, n, K): # write code here # 快排 def fast_order(arr, no_k): left, right= 0, len(a...
Python3
2021-11-23
0
283
题解 | #实现二叉树先序,中序和后序遍历#
class TreeNode: def init(self, x): self.val = x self.left = None self.right = None 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 @param root TreeNode类 the r...
Python3
2021-11-23
0
330
题解 | #设计LRU缓存结构#
运用有序字典保存顺序。 from collections import OrderedDict class Solution: def LRU(self , operators: List[List[int]], k: int) -> List[int]: # write code here ...
Python3
2021-11-22
0
253
题解 | #比较版本号#
**短字符串后补零,再按照int逐位比较。 ** 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 比较版本号 @param version1 string字符串 @param version2 string字符串 @return int整型 class Solutio...
Python3
2021-11-20
1
343