Please tell the doubts in this Question

Please tell the doubts in this Question

I want to print the directions in this one like: -
1: If element is traversed while moving Down.
2: If element is traversed while moving Right.
3: If element is traversed while moving Up.
4: If element is traversed while moving Left.

And Also 3 2 7 before 2 3 9
As 9 came first while traversing.
That’s why

How can I do this one.

Please explain with an example
Input output pairs :slight_smile:

Like, It is a sparse matrix that’s why I input it like that: -
I/P: -

4 4 5
0 0 8
1 1 6
1 2 5
2 3 9
3 2 7
1 1

O/P: -

1 1 6 1
1 2 5 3
0 0 8 4
3 2 7 2
2 3 9 3

Bro, Smjh aagya kya?

Bro Yeh shi krdiya, I took the columns direction nd row directions in reverse.
Means it was travelling right first.

Ab directions kaise add kru.

Updated line 15,26,71
Added line 17

Now change mp values according to what u need

Sir Test Case nhi pass horha.
Wait lemme show.

This is Question
And In Given Test Case
Second waale ki direction galt aarhi.

Hey @cbcao263
You have to change line 10&11 a little bit
And I am not telling you what exactly ,figure that yourself :slight_smile:

   int dr[4] = {0, 1, 0, -1};
    int dc[4] = {1, 0, -1, 0};

Change them according to question

1 Like

Hogya Sir,
I just exchanged both of them.

Thanks a lot. :slight_smile:

1 Like

Sir, Yeh doosre method se implement krne ki koshish ki.

Usme thoda error aarha in o/p.
Aisa kyu


isme same error aarha as prev one

Hey @cbcao263
Its working fine on the given test case ,and I can’t debug without access to the question .

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.