Java Add (allow overflow) then adjust
Add directly, each digit will be between 0-2\n2. Adjust if overflow, for digit[i] if it\'s >=2\na) if digit[i-1]>=1, digit[i-1]--;\nb) else digit[i - 1]++; digi
1. Add directly, each digit will be between 0-2\n2. Adjust if overflow, for digit[i] if it\'s >=2\na) if digit[i-1]>=1, digit[i-1]--;\nb) else digit[i - 1]++; digit[i - 2]++;\n\n```\n\tpublic int[] addNegabinary(int[] arr1, int[] arr2) {\n\t\tint[] ret = new int[1020];\n\t\tfor (int i = 0; i < ret.length; i++) {\n\t\t\tint i1 = arr1.length - 1 - i;\n\t\t\tint a = (i1 >= 0 ? arr1[i1] : 0);\n\t\t\tint i2 = arr2.length - 1 - i;\n\t\t\tint b = (i2 >= 0 ? arr2[i2] : 0);\n\t\t\tint i3 = ret.length - 1 - i;\n\t\t\tret[i3] = a + b;\n\t\t}\n\t\tfor (int i = ret.length - 1; i > 2; i--) {\n\t\t\tif (ret[i] >= 2) {\n\t\t\t\tret[i] -= 2;\n\t\t\t\tif (ret[i - 1] >= 1)\n\t\t\t\t\tret[i - 1]--;\n\t\t\t\telse {\n\t\t\t\t\tret[i - 1]++;\n\t\t\t\t\tret[i - 2]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < ret.length; i++)\n\t\t\tif (ret[i] != 0)\n\t\t\t\treturn Arrays.copyOfRange(ret, i, ret.length);\n\n\t\treturn new int[] { 0 };\n\t}\n\n```
[]