Code giving wrong answer

Please check my code:

hello @Aparna
ur code is correct and giving correct output for the given graph.

image
this one is correct output for graph.
image

Oh yes, okay, thankyou