Time Limit Exceeded Error

Do I have to use hashmap for this shortest path problem. I used arraylist to construct the graph but it is showing TLE

Hey @ap8730390
Constraints is to big
use HashMap instead of ArrayList
You have implemented the bfs algorithm. This is the right way
you can see this

Okay… Thanks again. I need one more help on Beautiful Vertices problem. Can you look into that also please :frowning: There is minute error occuring in answer like where the answer should be 6538 it’s giving 6534.