I used a sliding window technique to maintain a subarray where all the elements are unique. I kept a set called seen to quickly check for duplicates and removed elements from the left of the window if a duplicate was encountered. For each unique window, I maintained the sum and updated the maximum sum encountered so far.
It didn't work and I checked the editorial, and it was a one-liner???
