Getting wrong answer

Hello, I used topological sort for the question but I’m getting the wrong answer.
code-https://ide.codingblocks.com/s/344539

@amanb25 hey
Try to understand the logic.
3
v
w
b
2
w v
b
same sequence of given input(v, w, b)
v–>
w—>
b—>

Given relation:
w v
drink w before v. So, v depends on w.
So, v—>w,

b w
drink b before w. So, w depends on b.
So, w—>b.

Now, the structure is:
v—>w,
w—>b
b—>

Now, check top to bottom which has zero dependency.
b has zero dependency. First drink b.
Now, delete b from structure because he already drunk the b.
And erase b from all elements which depends on b.
1st output is b.
Then, structure looks like below.
v—>w.
w—>

Again check top to bottom which has zero dependency. Now, find w.
Then he drink w.
Now, delete w from structure because he already drunk the w.
And erase w from all elements which depends on w.
2nd output is w.
Then, structure looks like below.
v—>

Again check top to bottom which has zero dependency. Now, find v.
Then he drink v.
Now, delete v from structure because he already drunk the v.
And erase v from all elements which depends on v.
3rd output is v.
Then, structure looks like below.
The structure is empty. end of loop.
So, the output is b w v.

i changed the ordering to do that but still get the wrong result.
code-https://ide.codingblocks.com/s/344539

hey @amanb25 refer this code.

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.