✅✔️Clean and Easy to understand Implementation in C++ ✈️✈️✈️✈️✈️
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 {\npublic:\n    int minSumOfLengths(vector<int>& arr, int target) {\n        int n = arr.size(), i = 0, sum = 0;\n\n        vector<int>left(n) , right(n);\n        int len = INT_MAX;\n        for(int j=0; j<n; j++){\n            sum += arr[j];\n            while(sum > target){\n                sum -= arr[i];\n                i++;\n            }\n            if(sum == target){\n                len = min(len,j-i+1);\n            }\n            left[j] = len;\n        }\n\n        i = n-1; sum = 0; len = INT_MAX;\n\n        for(int j=n-1; j>=0; j--){\n            sum += arr[j];\n            while(sum > target){\n                sum -= arr[i];\n                i--;\n            }\n            if(sum == target){\n                len = min(len,i-j+1);\n            }\n            right[j] = len;\n        }\n\n        int ans = INT_MAX;\n        for(int j=1; j<n; j++){\n            if(left[j-1] != INT_MAX && right[j] != INT_MAX) ans = min(ans,left[j-1] + right[j]);\n        }\n        return ans == INT_MAX ? -1 : ans;\n    }\n};\n```
['Array', 'Two Pointers', 'Prefix Sum', 'C++']