Why my solution can only pass 154/157 test case?


  • 0

    Why my solution can only pass 154/157 test case?I'm very confused.

    class Solution {
    public:
    	void setZeroes(vector<vector<int>>& matrix) {
    		int m = matrix.size();
    		int n = matrix[0].size();
    		long long m_record = 0;
    		long long n_record = 0;
    
    		for (size_t i = 0; i < m; i++)
    		{
    			for (size_t k = 0; k < n; k++)
    			{
    				m_record |= (matrix[i][k] == 0 ? 1 << k : 0);
    				n_record |= (matrix[i][k] == 0 ? 1 << i : 0);
    			}
    		}
    
    		for (size_t i = 0; i < m; i++)
    		{
    			if (((n_record >> i) & 1))
    			{
    				for (int k = 0; k < n; k++)
    				{
    					matrix[i][k] = 0;
    				}
    			}
    		}
    
    		for (size_t i = 0; i < n; i++)
    		{
    			if (((m_record >> i) & 1))
    			{
    				for (size_t k = 0; k < m; k++)
    				{
    					matrix[k][i] = 0;
    				}
    			}
    		}
    	}
    };
    

Log in to reply
 

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