class Node
{
string key_;
vector<Node*> out_edges;
};
class Solution
{
public:
vector<Node*> compress_graph(vector<Node*> start_nodes)
{
// todo: implement
return {};
}
};// f - -> END
// | |
// v |
// u -> l -> l -> e -> s -> t -> END
// ^ |
// | |
// d - - > r -> END// f - -> END
// | |
// v |
// ull -> e -> st -> END
// ^ |
// | |
// d - - r -> ENDIt was a disaster. I have solved 250 problems on LC including graph traversal (# of islands, walls and gates )but I for some reason
invented my own way of graph traversal. Basically, since the graph did not look like a typical graph I was thrown. However, what I should have done is stayed on track and implemented DFS or BFS.
Importantly, I want to learn from my mistakes hence this post.
Bascially, I want to know if there is a proper known way e.g algorithm or approach to solve the problem