my first python beats 100%
Pretty straightforward solution with O(n) time and space complexity. my first python 100% beats on leetcode over 400 tasks\n\n\n    def minSubarray(self, nums: 
Pretty straightforward solution with O(n) time and space complexity. my first python 100% beats on leetcode over 400 tasks\n\n\n    def minSubarray(self, nums: List[int], p: int) -> int:\n        result = len(nums)\n\t\t# reminder that we need to remove from given array\n        need = sum(nums) % p\n\t\t# exit if nothing to remove\n        if need == 0:\n            return 0\n\t\t# at the beginning our prefix sum is zero with location -1 for correct length calculations for subarrays starting at 0\n        prefix_pos = {0: -1}\n\t\t# current prefix sum\n        prefix = 0\n        for i, num in enumerate(nums):\n\t\t\t# increase prefix by current num and take reminder\n            prefix = (prefix + num) % p\n\t\t\t# this is the current value we need to find in already seen positions\n            cur = (prefix - need) % p\n\t\t\t# if it\'s present calculate and update result if necessary\n            if cur in prefix_pos:\n                result = min(i - prefix_pos[cur], result)\n\t\t\t# remember current prefix position\n            prefix_pos[prefix] = i\n\t\t# if the only available result is the whole array, than it should be -1 \n        if result == len(nums):\n            result = -1\n        return result
[]