别踩我尾巴
别踩我尾巴
全部文章
分类
题解(9)
归档
标签
去牛客网
登录
/
注册
别踩我尾巴的博客
全部文章
(共25篇)
题解 | 缺失的第一个正整数
class Solution: def minNumberDisappeared(self , nums: List[int]) -> int: # write code here # nums.sort() # 对字典和对列表使用in ...
2025-09-20
0
20
题解 | 数组中只出现一次的两个数字
class Solution: def FindNumsAppearOnce(self , nums: List[int]) -> List[int]: # write code here # 直接写返回res,第一次出现时加入,若发现已经存在删除好了,...
2025-09-20
0
14
题解 | 数组中出现次数超过一半的数字
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param numbers int整型一维数组 # @return int整型 # class Solution: def MoreThanHalfNum_Solution(self , nu...
2025-09-20
0
16
题解 | 两数之和
class Solution: def twoSum(self , numbers: List[int], target: int) -> List[int]: # # write code here # 暴力做法超时 # for i i...
2025-09-20
0
14
题解 | 买卖股票的最好时机(二)
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 计算最大收益 # @param prices int整型一维数组 股票每一天的价格 # @return int整型 # class Solution: def maxProfit(self , pric...
2025-09-20
0
20
题解 | 买卖股票的最好时机(一)
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param prices int整型一维数组 # @return int整型 # class Solution: def maxProfit(self , prices: List[int])...
2025-09-20
0
13
题解 | 连续子数组的最大和
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param array int整型一维数组 # @return int整型 # class Solution: def FindGreatestSumOfSubArray(self , arr...
2025-09-20
0
17
题解 | 大整数哈希
n = int(input()) # 用字典定义一个哈希表 dic = {} sum =0 for i in range(n): x,y = map(int,input().split()) if x not in dic: dic[x]=y else: ...
2025-09-18
0
21
题解 | 字符串哈希
import sys # for line in sys.stdin: n = sys.stdin.read().splitlines() a = set(n) print(len(a)-1) set(可迭代对象)初始化集合,最后结果-1,是第一行的数字
2025-09-18
0
20
题解 | 最大子段和
n = int(input()) a = list(map(int,input().split())) dp = [0]*n dp[n-1]=a[n-1] res = a[n-1] for i in range(n-2,-1,-1): if dp[i+1]>0: dp[...
2025-09-17
0
18
首页
上一页
1
2
3
下一页
末页