I have a query regarding the approach to solving Sum and GCD problem.
My approach was to solve by greedy approach by simply taking two sets let A and B.
And putting the first two elements in both sets.
Now for every
i>2 we have three choices.
1. Put in set A 2. put in set B 3 .merge set A and B make a new set For ith element.
Out of all three choices take the maximum
I tried every case I can think of but got the wrong answer. By another approach I got AC but I wonder where I was wrong.
Here is my submission link