Why is this isn’t working?
Please help.
Please tell any other optimized approach that you can think of.
Why is this isn’t working?
Please help.
Please tell any other optimized approach that you can think of.
Hey @cbcao263
What you are doing is finding min in ith row and then traversing that row to check if its maximum as well
Instead do this
Find min,its index in every row then check its column if its maximum or not
Am I not checking in the Column as For every i I am changing j
Therefore mat[i][j] is changing the columns.
No changing j means u are traversing the row not the column
Sir, Like it is a vector in vector.
Think it as a 2D Matrix
Let’s in first case when i=0
I took j=0 till mcol
means it will traverse m[0][0] then m[0][1] and till m[0][mcol-1]
Here You can check 0 is fixed which is the row number and j(column) is changing.
Am I wrong or right
?
Yeah u are absolutely correct but
m[0][0] m[0][1] m[0][2] is 0 th row all elements
And u have to check the columns
so it should be say u get min of ith row at k
then m[0][k] m[1][k]… u have to check this
when u print a 2d matrix u do
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
}
}
This print row wise correct
Is it correct now
Nope
Do one thing
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.