Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
For every node sequence of length 4, there are 3 relevant edges. How can we consider valid triplets of edges?
Fix the middle 2 nodes connected by an edge in the node sequence. Can you determine the other 2 nodes that will give the highest possible score?
The other 2 nodes must each be connected to one of the middle nodes. If we only consider nodes with the highest scores, how many should we store to ensure we don’t choose duplicate nodes?
For each node, we should store the 3 adjacent nodes with the highest scores to ensure we can find a sequence with no duplicate nodes via the method above.