public static int[][] zeroifyMatrix(int[][] in) {
		if (in == null) {
			return null;
		}
		
		if (in.length == 0) {
			return in;
		}
		
		final int M = in.length;
		final int N = in[0].length;
		Set<Integer> rows = new HashSet<Integer>();
		Set<Integer> cols = new HashSet<Integer>();
		
		// O(n^2) space, O(n) time
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < N; j++) {
				if (in[i][j] == 0) {
					rows.add(i);
					cols.add(j);
				}
			}
		}
		
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < N; j++) {
				if (rows.contains(i) || cols.contains(j)) {
					in[i][j] = 0;
				}
			}
		}
		
		return in;
	}