Easy Python solution


  • 0
    J

    Hi Guys, I am a learner and I would like to understand even though my solution gets accepted I don't see it in the discussion so probably it is sub-optimal, because I am using the max() function of Python:

        def maxSlidingWindow(self, nums, k):
            i = 0
            maxlst = []
            if len(nums) == 1:
                return nums
            if nums == []:
                return maximus
            while j <= len(nums):
                maxlst.append(max(nums[i:k]))
                i+=1
                k+=1
            return maximus
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.