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

Anibel - Edges - Matrix Checksum #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anibelamerica
Copy link

Time complexity: O(n^2) where n is the length of the column or row of the input matrix (square matrix). This is because the algorithm iterates through each value in the matrix to get the sum for that column/row and then additionally compares the stored hash of 2*n values to return a boolean: O(n^2 + 2*n) but since 2*n is less significant than n^2, we can drop that value from the time complexity.

Space complexity: O(n) where n is the same as above. We end up using 2 hashes of size n but drop the constant in Big O notation.

@shrutivanw
Copy link

Nice work on the algorithm!

The problem statement encourages you to minimize the space complexity as much as possible. With that in mind, can you think of further optimizations to your algorithm? After you have given it some thought, tally your new algorithm to mine here: https://github.com/Ada-C10/matrix_check_sum/blob/solution/lib/matrix_check_sum.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