Skip to content

Instantly share code, notes, and snippets.

@nhuntwalker
Last active December 8, 2017 17:42
Show Gist options
  • Save nhuntwalker/22ba0b1077ee499708669e3859b4a564 to your computer and use it in GitHub Desktop.
Save nhuntwalker/22ba0b1077ee499708669e3859b4a564 to your computer and use it in GitHub Desktop.
Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0.
Ex:
input matrix = [
[0, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[1, 5, 0, 7, 33],
[6, 7, 8, 9, 10],
[6, 7, 8, 9, 10],
]
output = [
[0, 0, 0, 0, 0],
[0, 7, 0, 9, 10],
[0, 0, 0, 0, 0],
[0, 7, 0, 9, 10],
[0, 7, 0, 9, 10],
]
Email to nicholas@codefellows.com by 9:56am
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment