记录自己的成长,加油。
class Solution {
public int findMaxK(int[] nums) {
int k = -1;
Set<Integer> set = new HashSet<Integer>();
for (int x : nums) {
set.add(x);
}
for (int x : nums) {
if (set.contains(-x)) {
k = Math.max(k, x);
}
}
return k;
}
}