Sumagcd doubt

Can someone pls tell the error in this solution. It is not passing task number 2 in subtask 1.
https://www.codechef.com/viewsolution/24847690

removing duplicates at array size = 2 is problematic
example
[134,134]
remove duplicates = [134]
GCD sum = 134 (even there is only one set)
but we can choose sets such that
B = [134]
C = [134]
GCD( B ) + GCD( C ) = 268

2 Likes

Right. You can use a HashSet to input the array first and handle the edge cases of the set having size 1 and 2. 1 meaning all elements are same, 2 meaning there are 2 unique elements in the array)

Is HashSet like unordered_set in C++(Heard first time)?

I suppose. HashSet in Java is used to store unique values only.