题解 | #滑动窗口的最大值#

滑动窗口的最大值

https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788

# 感觉本题未达到较难难度,应该是简单难度
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param num int整型一维数组 
# @param size int整型 
# @return int整型一维数组
#
class Solution:
    def maxInWindows(self , num: List[int], size: int) -> List[int]:
        # write code here
        res=[]
        if size>len(num) or size==0:
            return res
        for i in range(len(num)-size+1):
            res.append(max(num[i:i+size]))
        return res

全部评论

相关推荐

天降大厂offer:你是我见过最美的牛客女孩
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务