python super easy to understand prefix + suffix
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minSumOfLengths(self, arr: List[int], target: int) -> int:\n        \n\n        prefix = [float("inf")] * len(arr)\n        \n        index = {0:-1}\n        s = 0\n        shortest_length = float("inf")\n        for i in range(len(arr)):\n            s += arr[i]\n            if s - target in index:\n               shortest_length = min( shortest_length, i - index[s-target])\n       \n            prefix[i] =  shortest_length\n            index[s] = i\n        \n        index = {0:len(arr)}\n        s = 0\n        shortest_length = float("inf")\n        ans = float("inf")\n        for i in range(len(arr)-1, 0, -1):\n            s += arr[i]\n            if s - target in index:\n                 shortest_length = min( shortest_length, index[s-target]-i)\n            ans = min(ans, prefix[i-1]+ shortest_length)\n            index[s] = i\n        return ans if ans != float("inf") else -1\n      \n\n```
['Prefix Sum', 'Python3']