Online Assessment question - Roads and cities Not working - Need HELP

Below question has been asked in an online assessment but I couldn't able to complete. It would be great if you can help me know how we can write code in JAVA. I had tried using adjacency list but not happened.
Appreciate your reply. Thank you.image

image
image

Comments (0)