lee≤e
lee≤e
全部文章
题解
归档
标签
去牛客网
登录
/
注册
leebobo
全部文章
/ 题解
(共21篇)
题解 | #寻找峰值#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param nums int整型一维数组 # @return int整型 # class Solution: def findPeakElement(self , nums: List[int])...
Python3
2022-04-19
0
368
题解 | #寻找第K大#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param a int整型一维数组 # @param n int整型 # @param K int整型 # @return int整型 #reverse=True,sort倒序排列 class Sol...
Python3
2022-04-18
0
325
题解 | #排序#
#好使,速度超过99%的python代码 class Solution: def MySort(self , arr: List[int]) -> List[int]: # write code here return sorted(arr)
Python3
2022-04-18
0
321
题解 | #反转数字#
#先把x转为字符串判断是不是负数,然后切片反转,最后再转为int判断大小是不是在范围内 class Solution: def reverse(self , x: int) -> int: # write code here x=str(x) ...
Python3
2022-04-18
0
336
题解 | #翻转单词#
#将字符串中以空格为分隔符加入到列表l中 #再将l中元素以空格为分隔符连接成新的字符串,否则返回的是列表 class Solution: def reverseWord(self , str: str) -> str: # write code here ...
Python3
2022-04-18
0
394
题解 | #打印从1到最大的n位数#
#生成 1-10的n次方-1 的列表 class Solution: def printNumbers(self , n: int) -> List[int]: # write code here return [i for i in range(1,1...
Python3
2022-04-18
0
317
题解 | #数组里面没有出现过的数字#
#生成1-len(nums)的区间,再讲区间内元素与nums内元素比较,nums内没有该元素就把他添加进列表l2,set(nums)主要是为了去重,加快查找速度(nums去重前ac 790ms 5832kb,去重后56ms 6392kb)拿空间换时间 class Solution: def ...
Python3
2022-04-18
0
378
题解 | #调整数组顺序使奇数位于偶数前面(二)#
#用两个列表分别用来存奇数和偶数,最后奇数列表和偶数列表连接起来就行,时间复杂度满足,就是空间浪费了挺多 class Solution: def reOrderArrayTwo(self , array: List[int]) -> List[int]: # write...
Python3
2022-04-18
0
271
题解 | #平方升序数组#
#遍历数组nums,把每一个元素(nums[i])全部平方再赋值给nums[i] class Solution: def sortedArray(self , nums: List[int]) -> List[int]: # write code here ...
Python3
2022-04-18
0
440
题解 | #斐波那契数列#
#用递归会方便一点,这写法太cao了,三个变量轮流存 class Solution: def Fibonacci(self , n: int) -> int: # write code here f1,f2,sun=1,1,0 if n=...
Python3
2022-04-18
0
313
首页
上一页
1
2
3
下一页
末页