C++ Solution with Detailed Explanation
According to the constraints, we know that values stored in "arr" are all positive value.\nWhich give us 2 preconditions:\n1. there\'s no duplicates if we calcu
According to the constraints, we know that values stored in "arr" are all positive value.\nWhich give us 2 preconditions:\n1. there\'s no duplicates if we calculate accumulative sum "Accum" for all possible value of i. (0 <= i < arr.size())\n- Accum[i] stores the sum of arr[0] + arr[1] + ... + arr[i] \n2. "Accum" array is in increasing order.\n\nWith above preconditions, \n1. We loop through "arr" for the first time and setup a hash table "tbl" that store {accum[i], i} as {key, value} pair.\n2. Loop through "arr" again, this time we keep track of current accumulative sum "sum". (current index).\n3. if "sum - target" exist in the hash table, which means there\'s a subarray on the left and ends at index i with length of i - tbl[sum - target].  Update the "l_len" to keep track of minimum length of left subarray .\n- Since "sum" and "target" are both positive integer and accum[i] is in increasing order, tbl[sum - target] would guarantee to be smaller than i\n4. if "sum + target" exist in the hash table, which means there\'s a subarray on the right that starts from index i + 1 with length of tbl[sum + target] - i. Update "ret" to keep track of minimum sum of two subarray length.\n\nNote that Step#3 & #4 would guarantee two subrarry are non-overlapping.\n\n\n```\nint minSumOfLengths(vector<int>& arr, int target) {\n        unordered_map<int, int> tbl;\n        int sum = 0;\n        for (int i = 0; i < arr.size(); i++) {\n            sum += arr[i];\n            tbl[sum] = i;\n        }\n        int l_len = INT_MAX;\n        int ret = INT_MAX;\n        sum = 0;\n        for (int i = 0; i < arr.size(); i++) {\n            sum += arr[i];\n            if (tbl.count(sum - target))\n                l_len = min(l_len, i - tbl[sum - target]);\n            else if (sum == target)\n                l_len = min(l_len, tbl[sum] + 1);\n            if (tbl.count(sum + target) && l_len != INT_MAX)\n                ret = min(ret, tbl[sum + target] - i + l_len);\n        }\n        return (ret == INT_MAX) ? (-1):(ret);\n    }\n```
[]