Wednesday, December 19, 2012

Set Row and Column to Zero if Element is Zero

Book: Cracking the Coding Interview
Question: 1.7 (page 73)

Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0.

Solution: Complexity - O(M*N), Space - O(M+N)


No comments:

Post a Comment