https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers/



Runtime: 144 ms, faster than 79.09% of JavaScript online submissions for Check if Every Row and Column Contains All Numbers.

Memory Usage: 51.2 MB, less than 12.36% of JavaScript online submissions for Check if Every Row and Column Contains All Numbers.



```javascript
var getColumn = function(matrix, col) {
   var column = [];
   for(var i=0; i<matrix.length; i++){
      column.push(matrix[i][col]);
   }
   return column; 
}

let areSetsEqual = (a, b) => a.size === b.size && [...a].every(value => b.has(value));

var checkValid = function(matrix) {
    //7:42
    let n = matrix.length;
    let num_set = new Set()
    let range_list = Array.from(Array(n).keys())
    range_list.forEach(function (item, index) {
        num_set.add(item+1);
    });
    
    for (const index of range_list) {
        let column = getColumn(matrix, index)
        let row = matrix[index]
        
        if (areSetsEqual(new Set(row), num_set) === false) {
            return false;
        }
        
        if (areSetsEqual(new Set(column), num_set) === false) {
            return false;
        }
    }
    
    return true
    //7:57
};
```
