Difficulty Level : Easy
Submissions : 3206
Asked In :
Marks :10
: 62 | : 3
You are given $$$N$$$ buildings and $$$M$$$ pairs of building denoting which pair of buildings are close enough to jump from one another. Given current building you are at and final building where you want to be at, find out minimum number of jumps required.
If it is not possible to reach to final building, print $$$0$$$.
First line contains two integers $$$N$$$ & $$$M$$$, denoting number of buildings and number of pairs of building that are close enough to jump from one another.
Next $$$M$$$ lines contain two integers each denoting buildings which are close enough.
Last line of input contains two integers denoting building you are starting at and building you want to reach.
Print minimum number of jumps required to reach final building. If it is not possible then print "$$$0$$$".
5 5 1 3 2 3 1 2 3 5 4 5 1 4
3
5 3 1 3 1 2 4 5 1 4
0
$$$1 \leq N \leq 4000$$$
$$$1 \leq M \leq 10^{6}$$$
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.