To keep track of visited nodes and parent child relationship, if I use hashMap instead of Array of Int. It gets TLE.