Python3 Sliding Window Based Solution
```\n"""https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/"""\n\n\nclass Solution:\n    def minSumOfLengths(self, arr: List
```\n"""https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/"""\n\n\nclass Solution:\n    def minSumOfLengths(self, arr: List[int], target: int) -> int:\n        left, partial_sum, min_len = 0, 0, float(\'inf\')\n        # records the smallest length of subarry with target sum until index i\n        min_so_far = [float(\'inf\')] * len(arr)\n        for right, num in enumerate(arr):\n            partial_sum += num\n            while partial_sum > target:\n                partial_sum -= arr[left]\n                left += 1\n            if partial_sum == target:\n                curr_len = right - left + 1\n                min_len = min(min_len, curr_len + min_so_far[left - 1])\n                min_so_far[right] = min(curr_len, min_so_far[right - 1])\n            else:\n                min_so_far[right] = min_so_far[right - 1]\n        return min_len if min_len < float(\'inf\') else -1\n
[]