73. Set Matrix Zeroes

1.問題

  • 如果行列中有元素為0, 讓整行或整列為0

2.想法

  • 提問:

  • function header, parameter

  • test input

  • 說明想法

    • 先標記0的位置, 掃描若為被標記的位置則將其row, col設為0

  • 測試計算複雜度

3.程式碼

  • O (m + n)解:

  • O(1)解: 用第一行, 列記錄

4.Performance

Last updated