Professional Documents
Culture Documents
Question
Question
2. Given A = [0, 0, 2, 1, 8, 8, 2, 0], B = [8, 5, 2, 4, 0, 0, 0, 2], your function should return 31. One possible sequence of
moves is as follows:
3. Given A = [109, 109, 109, 0, 0, 0], B = [0, 0, 0, 109, 109, 109], your function should return 999999972. Possible
sequence of moves:
The total number of turns is 5*109, so the answer is 5*109 mod (109+7) = 999999972.
4. Given A = [2] and B = [1] your function should return −1.
Write an efficient algorithm for the following assumptions: