Short JavaScript Solution Using a Set Object
Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n\nco
Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n```\nconst findMaxK = (nums) => {\n    let numsSet = new Set(nums)\n    let largestInteger = -Infinity\n\n    for (let num of numsSet) {\n        if (num > 0 && numsSet.has(-num)) {\n            largestInteger = Math.max(largestInteger, num)\n        }\n    }\n\n    return largestInteger === -Infinity ? -1 : largestInteger\n};\n```
['JavaScript']