Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacquelyn Cheng - Matrix Convert to 0 #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jacquelynoelle
Copy link

Time complexity O(n*m)
Space complexity O(n+m)

@shrutivanw
Copy link

Nicely done! 👍

The only further optimization I could think of was to use the 0th row and the 0th column of the input matrix to track which columns and which rows to convert to zeroes instead of creating new arrays. This reduces the space complexity to O(1). Here's the solution for that: https://github.com/Ada-C10/matrix_convert_to_zero/blob/solution/lib/matrix_convert_to_zero.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants