Standard addition of lists with tricky carry
Here we use the same technique as for adding two lists with carry\nbut the tricky part is the calculation of the carry.\nIf the sum is positive then just take t
Here we use the same technique as for adding two lists with carry\nbut the tricky part is the calculation of the carry.\nIf the sum is positive then just take the remainer as carry and multiply it to -1.\nIf the sum is -1 then the carry becomes 1.\n```\n    vector<int> addNegabinary(vector<int>& arr1, vector<int>& arr2) {\n        reverse(arr1.begin(), arr1.end());\n        reverse(arr2.begin(), arr2.end());\n        int n = arr1.size();\n        int m = arr2.size();\n        int carry = 0;\n        int i = 0, j = 0;\n        vector<int> res;\n        // Add to res while there is something to add\n        while (true) {\n            // When ther is no more to add break\n            if (carry == 0 && i == n && j == m) break;\n            int x1 = i < n ? arr1[i++] : 0;\n            int x2 = j < m ? arr2[j++] : 0;\n            int sm = x1 + x2 + carry;\n            res.push_back(abs(sm % 2));\n            // This is the tricky part\n            carry = sm >= 0 ? -sm / 2 : 1;\n        }\n        while (res.size() > 1 && res.back() == 0) \n            res.pop_back();\n        reverse(res.begin(), res.end());\n        return res;\n    }\n```
[]