[Python3] simple O(n) beginner friendly!
First, convert the nums into a set for quick access.\nSecond, go over the entire nums, for each element k, do:\n1. check if k is positive.\n2. check if -k exist
First, convert the nums into a set for quick access.\nSecond, go over the entire nums, for each element k, do:\n1. check if k is positive.\n2. check if -k exist in nums using the set, which takes O(1).\n3. check if k is larger than the largest element we have seen so far. And if it is, update the largest element so far and the result.\n\n```\nclass Solution:\n    def findMaxK(self, nums: List[int]) -> int:\n        Set = set(nums) ### convert nums into a set\n        maxSoFar = -inf\n        res = -inf\n        for n in nums:\n        \t### check condition 1-3\n            if n>0 and -n in Set and n>maxSoFar:\n                maxSoFar = n\n                res = n\n        ### If there is no such integer (res==-inf which never got updated), return -1.\n        return res if res!=-inf else -1\n```\n\n**Upvote** if you like this post.\n\n**Connect with me on [LinkedIn](https://www.linkedin.com/in/meida-chen-938a265b/)** if you\'d like to discuss other related topics\n\n\uD83C\uDF1F If you are interested in **Machine Learning** || **Deep Learning** || **Computer Vision** || **Computer Graphics** related projects and topics, check out my **[YouTube Channel](https://www.youtube.com/@meidachen8489)**! Subscribe for regular updates and be part of our growing community.
[]