[C++] Count Negative | Easy Solution
Approach : By the given operation we can make any cell negative (we are able to move -ve sign everywhere) .\nNow there are two conditions -\n1) count of -ve ele
**Approach** : By the given operation we can make any cell negative (we are able to move -ve sign everywhere) .\nNow there are two conditions -\n1) count of -ve elements are even , if so then we can able to remove all -ve\'s , means answer is sum of absoulute value of each cell.\n2) count of -ve elements are odd , if so then we can able to remove all -ve\'s , except one -ve element and we will make -ve which cell ? , the cell which have least absolute value so the answer is sum of  absoulute value of each cell - 2* min value *(why ? , let say we have array a =[1,2,3,4] sum is 10 but we apply one -ve sign before 3 so array is [1,2-3,4] sum is 4 which is same as 10-2  (3) = 4]*\n\n**Below is the solution -**\n```\nclass Solution {\npublic:\n    long long maxMatrixSum(vector<vector<int>>& mat) {\n        long long int sum = 0 , mini = INT_MAX ,  cnt=0;\n\t\tint n=mat.size();\n        for(int i=0;i<n;i++){\n\t\t\tfor(int j=0;j<n;j++){\n                sum += abs(mat[i][j]);\n                if(mat[i][j]<0)\n                    cnt++;\n                mini = min(mini , abs(mat[i][j])*1LL);\n            }\n        }\n        if(cnt%2)\n            return sum-2*mini;\n        else\n            return sum;\n    }\n};\n```\n**Upvote if you like \u2764\uFE0F**
['C', 'Matrix']