C# Solution for Largest Positive Integer That Exists With Its Negative Problem
Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind this C# solution is to utilize two pointers starting from both end
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind this C# solution is to utilize two pointers starting from both ends of the sorted array, moving towards each other to efficiently find pairs of numbers that sum up to zero.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.\tSort the array to simplify the search process.\n2.\tInitialize two pointers, left starting from the beginning of the array, and right starting from the end.\n3.\tMove the pointers towards each other while checking the sum of the elements pointed by them.\n4.\tIf the sum is zero, it means we found a pair where one element is the negative of the other. Update maxK if necessary and move both pointers inward.\n5.\tIf the sum is negative, increment the left pointer to increase the sum.\n6.\tIf the sum is positive, decrement the right pointer to decrease the sum.\n7.\tReturn maxK or -1 if no such k exists\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\u2022\tSorting the array takes O(n log n) time.\n\u2022\tThe two-pointer approach traverses the array once, which has a time complexity of O(n).\n\u2022\tThus, the overall time complexity is O(n log n) due to sorting.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity is O(1) because the solution only utilizes a constant amount of extra space for variables like maxK, left, and right, regardless of the size of the input array.\n\n# Code\n```\npublic class Solution {\n    public int FindMaxK(int[] nums) {\n        Array.Sort(nums);\n        int maxK = -1;\n        \n        int left = 0, right = nums.Length - 1;\n        while (left < right) {\n            int sum = nums[left] + nums[right];\n            if (sum == 0) {\n                maxK = Math.Max(maxK, Math.Abs(nums[right]));\n                left++;\n                right--;\n            } else if (sum < 0) {\n                left++;\n            } else {\n                right--;\n            }\n        }\n        \n        return maxK;\n    }\n}\n```
['C#']