Here is the code and problem i am getting segmentation fault pls help

https://practice.geeksforgeeks.org/problems/rotten-oranges2536/1/?category[]=Graph&page=1&query=category[]Graphpage1#

hello @Vipul.kapoor
share ur code link as well. u have only shared the question link

input and output would be from driven system
here is only the logic

@Vipul.kapoor
check now->

runtime error is coming

now it passed the test cases
thankss

image

it is working fine, make sure u copied the code correctly

yeah sir it passed
please explain me the line number 43 of your code

first we need to valid thhe index , if it is valid then only we can access the index.
thats the reason i put check first