C++ solution using 2 carry
\nMy solution using two carry: \n\n\n2* (-2)^i = (-2)^(i+1) + (-2)^(i+2); // current = 0, carry1 = 1 and carry2 = 1\n3* (-2)^i = (-2)^i + (-2)^(i+1) + (-2)^(i+2
\nMy solution using two carry: \n\n```\n2* (-2)^i = (-2)^(i+1) + (-2)^(i+2); // current = 0, carry1 = 1 and carry2 = 1\n3* (-2)^i = (-2)^i + (-2)^(i+1) + (-2)^(i+2) // current = 1, carry1 = 1 and carry2 = 1\n4* (-2)^i = (-2)^(i+2); // current = 0, carry1 = 0 and carry2 = 1\n```\n```\nvector<int> addNegabinary(vector<int>& arr1, vector<int>& arr2) {\n\tvector<int> ret;\n\tdeque<int> res(max(arr1.size(), arr2.size()));\n\tunordered_map<int, int> carry;\n\tint i, j;\n\tfor (i = arr1.size() - 1, j = arr2.size() - 1; i >= 0 || j >= 0; i--, j--){\n\t\tint idx = max(i, j);\n\t\tint sum = carry[idx];\n\t\tif (i >= 0) sum += arr1[i];\n\t\tif (j >= 0) sum += arr2[j];\n\t\tif (sum == 0) res[idx] = 0;\n\t\telse if (sum == 1) res[idx] = 1;\n\t\telse if (sum == 2) res[idx] = 0, carry[idx - 1]++, carry[idx - 2]++;\n\t\telse if (sum == 3) res[idx] = 1, carry[idx - 1]++, carry[idx - 2]++;\n\t\telse res[idx] = 0, carry[idx - 2]++;\n\t}\n\tif (carry[-1] != 2 || carry[-2] != 1){\n\t\tif (carry[-1] == 1)res.push_front(1);\n\t\tif (carry[-2] == 1)res.push_front(1);\n\t}\n\tfor (auto e : res) {\n\t\tif (!e) res.pop_front();\n\t\telse break;\n\t}\n\tif (res.size() == 0) return{ 0 };\n\tstd::copy(res.begin(), res.end(), std::back_inserter(ret));\n\treturn ret;\n}\n```
[]