Time Complexity

Here if we do like this we will get the output. But if we do like this then our time complexity would be more right?
i think so we will get the O(n^6). So i am asking another solution which would take lesser time.

Hey @bharath_gopishetti, the time complexity in this case won’t be O(n^6).
It would be O(noe), where noe=Number Of Elements present in the matrix.
Each element is processed only once ie, we visit every element only once.
So, it’s complexity would be O(m*n) or O(noe) where m is the number of rows, n is the number of columns. You can relate it as a traversal of matrix, and the time complexity of traversal of a matrix is O(m * n).

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.