Easy Solution using C++ for Beginners using For Loop
Intuition\nReturn the value if the maximum positive element has its negative value in the array\n Describe your first thoughts on how to solve this problem. \n\
# Intuition\nReturn the value if the maximum positive element has its negative value in the array\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n# Sort the array\n\n**Use 2 for loops**\n\n- 1st loop iterates from first element to last(small to big)\n\n- 2nd loop iterates from last element to first(big to small)\n\n*By multiplying the 1st loop with -1, check if the 1st loop\'s value is equal to the 2nd loop which begins from larger value, if true return the 2nd loop\'s value, else return -1.*\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: 69.74%\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: 67.83%\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int findMaxK(vector<int>& nums) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        for(int i=0;i<n;i++)\n        {\n            for(int j=n-1;j>=0;j--)\n            {\n                if(nums[j]==(nums[i]*(-1)))\n                return nums[j];\n            }\n        }\n        return -1;\n    }\n};\n```
['C++']