class Solution(object):

    def findMaxAverage(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: float
        """
        S = 0
        for i in range(k):
            S += nums[i]
        kq = S
        for i in range(k, len(nums)):
            S += nums[i] - nums[i - k]
            if S > kq:
                kq = S
        return kq / float(k)

e78b2ce0eb620475431a909cc2e14a425e43e70e
<mask token>

class Solution(object):
    <mask token>

class Solution(object):

    def findMaxAverage(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: float
        """
        S = 0
        for i in range(k):
            S += nums[i]
        kq = S
        for i in range(k, len(nums)):
            S += nums[i] - nums[i - k]
            if S > kq:
                kq = S
        return kq / float(k)
