經典算法面試題目-置矩陣行列元素爲0(1.7)

題目 Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0. 寫一個函數處理一個MxN的矩陣,如果矩陣中某個元素爲0,那麼把它所在的行和列都置爲0. 解答 簡單題。遍歷一次矩陣,當遇到元素等於0時,記錄下這個元素對應的行和列。 可以開一個行數組r
相關文章
相關標籤/搜索