Handle sum for different case
Intuition\n Describe your first thoughts on how to solve this problem. \nThe solution to this problem is to figure out the math behind it, once that is done it 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe solution to this problem is to figure out the math behind it, once that is done it is simple to solve.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIf you think about it, there\'s only a few cases for the bit addition with the carryover, the solution is basically just handle the different cases.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n# Code\n```\nclass Solution {\npublic:\n\tpair<int, int> handleSum(int sum) {\n\t\tint bit = 0;\n\t\tint carry = 0;\n\n\t\tswitch (sum) {\n\t\t\tcase 0:\n\t\t\t\tbit = 0;\n\t\t\t\tcarry = 0;\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tbit = 1;\n\t\t\t\tcarry = 0;\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tbit = 0;\n\t\t\t\tcarry = -1;\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tbit = 1;\n\t\t\t\tcarry = -1;\n\t\t\t\tbreak;\n\t\t\tcase -1:\n\t\t\t\tbit = 1;\n\t\t\t\tcarry = 1;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow runtime_error("Should not have sum not in range [-1,3]");\n\t\t}\n\n\t\treturn make_pair(bit, carry);\n\t}\n\n    vector<int> addNegabinary(vector<int>& arr1, vector<int>& arr2) {\n\t\tvector<int> bits;\n        int i = (int)arr1.size() - 1;\n        int j = (int)arr2.size() - 1;\n\t\tint idx = max(i, j);\n\n\t\tint bit = 0;\n\t\tint carry = 0;\n\n\t\t// Process the arithmetic for all given bits\n\t\twhile (idx >= 0) {\n\t\t\tint x1 = i >= 0 ? arr1[i] : 0;\n\t\t\tint x2 = j >= 0 ? arr2[j] : 0;\n\n\t\t\ttie(bit, carry) = handleSum(x1 + x2 + carry);\n\n\t\t\tbits.push_back(bit);\n\t\t\ti--;\n\t\t\tj--;\n\t\t\tidx--;\n\t\t}\n\n\t\t// Process the leftovers\n\t\twhile (bit != 0 || carry != 0) {\n\t\t\ttie(bit, carry) = handleSum(carry);\n\t\t\tbits.push_back(bit);\n\t\t}\n\n\t\t// Reverse the bits (because we\'re insert at the back)\n\t\treverse(bits.begin(), bits.end());\n\n\t\t// Clean up the leading zeroes\n\t\twhile (bits[0] == 0 && bits.size() > 1)\n\t\t\tbits.erase(bits.begin());\n\n\t\treturn bits;\n    }\n};\n\n// [1,1,1,1,1]\n//     [1,0,1]\n//          0\n\n// [0]\n// [0]\n// ---\n// [0] = 0 (bit = 0, carry = 0)\n\n// [0]\n// [1]\n// ---\n// [1] = 1 (bit = 1, carry = 0)\n\n//     [1]\n//     [1]\n// -------\n// [1,1,0] = 4 - 2 = 2 (bit = 0, carry = -1) \n\n//     [1]\n//     [1]\n//     [1]\n// -------\n// [1,1,1] = 4 - 2 + 1 = 3 (bit = 1, carry = -1) \n\n//    [-1]\n// -------\n//  [1, 1] (bit = 1, carry = 1)\n```
['C++']