Offer_リストは、_最大スライディングウィンドウを受賞します

スライディングウィンドウの最大

ここに画像を挿入説明
アイデア:トラバース

# -*- coding:utf-8 -*-
class Solution:
    def maxInWindows(self, num, size):
        # write code here
        if size == 0:
            return []
        length = len(num) - size + 1
        max_count = []
        for i in range(0, length):
            max_count.append(max(num[i:i+size]))
        return max_count
公開された31元の記事 ウォンの賞賛0 ビュー737

おすすめ

転載: blog.csdn.net/freedomUSTB/article/details/105012576