Suppose a graph has N node. 1<=N<=10^5
You are being querried Q times with starting and ending node. 1<=Q<=10^6.
What should be the approach for this? I found DFS would not be suitable here.
Question says you have graph with N node and N-1 edges. Each edges is assigned a lowercase english letter string. Then you will be asked Q queries in which you will be given two nodes and you have to find that the string you collected from edges in between given node can form a palindromic string or not. String length will be less than 20
eg :
3
1 3 ab
1 2 abc
3
1 3
2 3
3 3
ans:
no
yes
yes