2524. Largest Positive Integer That Exists With Its Negative
My accepted Python solution to LeetCode problem 2524, Largest Positive Integer That Exists With Its Negative, running in 10ms.
- Difficulty: Easy
- Python
- Runtime 10ms
- Memory 12.7MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 10ms, memory 12.7MB, accepted 2025-12-24.
class Solution(object):
def findMaxK(self, nums):
num_set = set(nums)
result = -1
for num in nums:
if num > 0 and -num in num_set:
result = max(result, num)
return result