[Python3] Sliding Window One Pass O(N)
```\nclass Solution:\n    def minSumOfLengths(self, arr: List[int], target: int) -> int:\n        res, cur, i, p = inf, 0, 0, [inf]\n        for j, a in enumera
```\nclass Solution:\n    def minSumOfLengths(self, arr: List[int], target: int) -> int:\n        res, cur, i, p = inf, 0, 0, [inf]\n        for j, a in enumerate(arr):\n            cur += a\n            while cur > target:\n                cur -= arr[i]\n                i += 1\n            if cur == target:\n                res = min(res, j-i+1+p[i])\n                p += min(p[-1], j-i+1),\n            else:\n                p += p[-1],\n        return res if res < inf else -1
[]