Dashboard Temp Share Shortlinks Frames API

HTMLify

LeetCode - Largest Positive Integer That Exists With Its Negative - Python
Views: 442 | Author: abh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Solution:
    def findMaxK(self, nums: List[int]) -> int:
        nums.sort()
        l = -1
        for n in nums:
            if n < 0:
                continue
            if -n in nums:
                if n > l:
                    l = n
        return l