Skip to content

Commit f5dd2f1

Browse files
committed
Time: 20 ms (45.91%), Space: 25.6 MB (39.56%) - LeetHub
1 parent 7348fe3 commit f5dd2f1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int findMaxK(vector<int>& nums) {
4+
map<int, bool> mp;
5+
for (auto& i : nums) {
6+
mp[i] = true;
7+
}
8+
int ans = -1;
9+
for (auto& i : mp) {
10+
if (mp.find(-i.first) != mp.end()) {
11+
ans = abs(i.first);
12+
break;
13+
}
14+
}
15+
return ans;
16+
}
17+
};

0 commit comments

Comments
 (0)