/**
* @param {number[]} nums
* @return {number}
*/
var findMaxK = function (nums) {
let k = -1
let seen = new Set(nums)
for (const num of nums) {
if (seen.has(-num)) {
k = Math.max(k, num)
}
}
return k
};
A very interesting question.
Top comments (0)