classSolution: defcountServers(self, grid: List[List[int]]) -> int: m = len(grid) n = len(grid[0]) # rowSum = [sum(grid[i]) for i in range(m)] # colSum = [sum(x) for x in zip(*grid)] rowSum = [0] * m colSum = [0] * n for i in range(m): for j in range(n): if grid[i][j] == 1: rowSum[i] += 1 colSum[j] += 1 count = 0 for i in range(m): for j in range(n): if grid[i][j] == 1and (rowSum[i] > 1or colSum[j] > 1): count += 1 return count