# MTRXMOD- Need some help in this question. I can't figure out the problem in my code/approach

In your solution from line 66 -73 you have checked the sign of that number but consider the case when the sign should be negative your code first goes to else condition to make sign[i][j]=1 but you don’t break the condition and continue further and now assume that the next element is 0 your loop will now enter if condition since it holds the equality and you will make the sign[i][j] = 0 again which is wrong.

I have made only one view on your code (majorly the main part) so please correct me if I am wrong and there can be more mistakes also.

You can take a look at my solution also.

One more thing I would like to point you always include the problem link in question so that coders who haven’t given this challenge can also help you!

sign[i][j] denotes whether i and j are having same sign i.e. 0 or opposite signs i.e. 1. not able to understand what you are trying to convey

What happens in your code when a[2] should be 0.All sign[2][i] in that case are 0 but it may be possible that some negative element should exist!

What happens next is you check all cases again for validity which sets your flag to 0. So you now revert the signs of all! but this is also wrong.

Also your solve() function is O(n^2) which exceeds Time limit !