Company: American_Express_SDE_Profile_11nov
Difficulty: medium
Base -2 Addition Problem Description In base -2, integers are represented by sequences of bits in the following way. Bits are ordered from the least to the most significant. The empty sequence represents 0. A sequence of bits B of length N represents the number: sum(B[i] * (-2)^i for i = 0 to N-1). Note that such a representation is suitable for both positive and negative integers. Write a function: class Solution { public int[] solution(int[] A, int[] B); } that, given two arrays of bits: A of length M, containing a sequence representing some integer X, and B of length N, containing a sequence representing some integer Y. returns the shortest sequence of bits representing X + Y. Result array should be returned as an array of integers. Examples Example 1: Here are some examples of base -2 representations and their decimal equivalents: 100111 represents -23 001011 represents -12 10011 represents 9 001 represents 4 Detailed breakdown of these conversions: | 1 | -2 | 4 | -8 | 16 | -32 | .