✅ [Python/Rust] fastest (100%) using two pointers, binary search (with detailed comments)
IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.\n\nPython. This solution employs sorting and a two-pointers approach. It demonstrated 127 ms runtime (100.00%) and use
**IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n\n**Python.** This [**solution**](https://leetcode.com/submissions/detail/823480874/) employs sorting and a two-pointers approach. It demonstrated **127 ms runtime (100.00%)** and used **14.2 MB memory (33.33%)**. Time complexity is log-linear (due to sorting): **O(N\\*logN)**. Space complexity is constant (in-place operations): **O(1)**. \n```\nclass Solution:\n    def findMaxK(self, nums: List[int]) -> int:\n        \n        # [1] two use two-pointers approach, we need\n        #     to prepare the list by sorting\n        nums.sort()\n        \n        # [2] move pointers towards each other to find\n        #     largest positive integer with its negative\n        i, j = 0, len(nums)-1\n        while i < j:\n            if nums[i] == - nums[j]:\n                return nums[j]\n            if abs(nums[i]) > abs(nums[j]):\n                i += 1\n            else:\n                j -= 1\n                \n        return -1\n```\n\n**Rust.** This [**solution**](https://leetcode.com/submissions/detail/823474467/) employs sorting and binary search. It demonstrated **0 ms runtime (100.00%)** and used **2.0 MB memory (100.00%)**. Time complexity is log-linear (due to sorting): **O(N\\*logN)**. Space complexity is constant (in-place operations): **O(1)**. \n```\nimpl Solution \n{\n    pub fn find_max_k(mut nums: Vec<i32>) -> i32 \n    {\n        // [1] to use binary search, we need\n        //     to prepare the list by sorting\n        nums.sort();\n        \n        // [2] now we can move from the right\n        //     and make binary search queries\n        for i in (0..nums.len()).rev()\n        {\n            match nums.binary_search(&(-nums[i]))\n            {\n                Ok(j) => return nums[i],\n                _ => {}\n            }\n        }\n        return -1;\n    }\n}\n```
['Python', 'Rust']