Strange C++ error, anybody can help? Thanks


  • 0
    S

    reference binding to misaligned address 0x000000000025 for type 'value_type', which requires 4 byte alignment

    class Solution {
    public:    
    int sumRegion(vector<vector<int>>& dp, int row1, int col1, int row2, int col2) {
    
    	return dp[row2 + 1][col2 + 1] - dp[row1][col2 + 1] - dp[row2 + 1][col1] + dp[row1][col1];
    }
    
    int maximalSquare(vector<vector<char>>& matrix) {
    	if (matrix.empty() || matrix[0].empty()) return 0;
    	int m = matrix.size();
    	int n = matrix[0].size();
    	vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
    	dp[0][0] = matrix[0][0]-'0';
    	for (int i = 1; i <= m; i++)
    	{
    		for (int j = 1; j <= n; j++)
    		{
    			dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + (matrix[i - 1][j - 1]-'0');
    		}
    	}
    	int maxl = min(m, n);
    	for (int i = maxl; i>0; i--)
    	{
    		for (int x = 0; i <= m - i; x++)
    		{
    			for (int y = 0; y <= n - i; y++)
    			{
    				if (sumRegion(dp, x, y, x + i - 1, y + i - 1) == i*i) return i*i;
    			}
    		}
    	}
    	return 0;
    }
    };
    

Log in to reply
 

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