scala solution
https://en.wikipedia.org/wiki/Negative_base#Addition\nscala []\nobject Solution {\n  val nMap = Map(\n    -2 -> (0,1), -1 -> (1,1), 0 -> (0,0),\n    1 -> (1,0),
https://en.wikipedia.org/wiki/Negative_base#Addition\n```scala []\nobject Solution {\n  val nMap = Map(\n    -2 -> (0,1), -1 -> (1,1), 0 -> (0,0),\n    1 -> (1,0), 2 -> (0,-1), 3 -> (1,-1)\n  )\n  def addNegabinary(arr1: Array[Int], arr2: Array[Int]): Array[Int] = {\n    def f(seq:Seq[(Int,Int)], c: Int = 0, \n          zero:Boolean=true, acc:Seq[Int] = Nil):Seq[Int] = {\n      lazy val (a,b) = seq.headOption.getOrElse((0,0))\n      lazy val (bit, carry) = nMap(a+b+c)\n      if(seq.isEmpty && c==0) if(zero) List(0) else acc.dropWhile(_ == 0)\n      else f(seq.drop(1), carry, zero&(bit==0), bit +: acc)\n    }\n    f(arr1.reverseIterator.toList zipAll (arr2.reverseIterator.toList,0,0)).toArray\n    \n  }\n}\n```
['Scala']