C++ Solution (Calculate Min Pair)


  • 0
    P
    int maxCount(int m, int n, vector<vector<int>>& ops) 
    {
    	if (ops.empty()) return m*n;
    	int minx = INT_MAX, miny = INT_MAX;
    	for (int i = 0; i < ops.size(); i++)
    	{
    		minx = min(minx, ops[i][0]);
    		miny = min(miny, ops[i][1]);
    	}
    	return minx*miny;
    }

  • -2
    J

    This is not right. You should not set minx and miny to INT_MAX. Try the input below and you will see why:

    3
    3
    [[4,4]]
    

  • 0
    P

    @Jowang Thank you for pointing out.
    However, the question says(Note:):
    The range of a is [1,m], and the range of b is [1,n].
    a,b can't be greater than m,n.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.