[C++] O(N) Simple Solution
\nint minSumOfLengths(vector<int>& arr, int target) {\n\tint ans = INT_MAX, prev_min = INT_MAX, left = 0, right = 0, curr = 0;\n\tqueue<pair<int, int>> q;\n\twh
```\nint minSumOfLengths(vector<int>& arr, int target) {\n\tint ans = INT_MAX, prev_min = INT_MAX, left = 0, right = 0, curr = 0;\n\tqueue<pair<int, int>> q;\n\twhile(right < arr.size()) {\n\t\tcurr += arr[right++];\n\t\twhile(curr > target && left < right) \n\t\t\tcurr -= arr[left++];\n\t\t\n\t\twhile(!q.empty() && q.front().second <= left) {\n\t\t\tprev_min = min(prev_min, q.front().second - q.front().first);\n\t\t\tq.pop();\n\t\t}\n\t\tif(curr == target) {\n\t\t\tif(prev_min != INT_MAX)\n\t\t\t\tans = min(ans, prev_min + right - left);\n\t\t\tq.emplace(left, right);\n\t\t}\n\t}\n\treturn ans == INT_MAX ? -1 : ans;\n}\n```
['C', 'Sliding Window', 'C++']