Graph Shortest Path Class

Programming Interview Hard 4 views
Back to Questions

Problem Description

Input provides {x}. Create Graph class with bfs(s,t) method. Output shortest distance or -1.

Input Format

First line n m. Next m lines u v. Last line s t.

Output Format

One integer distance.

Sample Test Case

Input:
5 5 1 2 2 3 3 4 4 5 1 5 1 4
Output:
3

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next