C++ , sliding widow easy simple solution
```\nclass Solution {\npublic:\n    int minSumOfLengths(vector& arr, int target) {\n        int n = arr.size();\n        vector dp(n, INT_MAX);\n        \n     
```\nclass Solution {\npublic:\n    int minSumOfLengths(vector<int>& arr, int target) {\n        int n = arr.size();\n        vector<int> dp(n, INT_MAX);\n        \n        int sum = 0;      \n        int ans = INT_MAX;\n        int len = INT_MAX;     \n        int start = 0;\n        int end = 0;\n        \n        for (end = 0; end < n; end++) {\n            sum += arr[end];\n            \n            while (sum > target) {\n                sum -= arr[start];\n                start++;\n            }\n            \n            if (sum == target) {\n                int curLen = end - start + 1;\n                if (start > 0 && dp[start-1] != INT_MAX) \n                {\n                    ans = min(ans, curLen + dp[start-1]); // ans will be the 2 sub-array length or current length + last min length( which is stored in dp)\n                }\n                len = min(curLen, len); \n            }\n            dp[end] = len;  // dp stores the previous min length\n        }\n        return ans == INT_MAX ? -1 : ans;\n    }\n};\n
['C', 'Sliding Window']