hey only one test case is not passing.
ide: https://ide.codingblocks.com/s/245123
Vivek and Party
@Vishal123 hey ,For this example output should be -:
5
A
B
C
D
E
5
C A
D A
B D
E B
E C
Output -: E B C D A
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.
bro can you tell me whats wrong in my solution?
@Vishal123 hey,
For this test case your code did not print A in the order of drinking.
5
A
B
C
D
E
5
C A
D A
B D
E B
E C
Pls try correcting this mistake ,if still some doubt i will send you corrected code.
can you send me corrected code
bro it is also not passing the last test case