I have a list of key/value pairs and I need to detect chains in the list where the value matches a key.
E.g. from the below there could be 12, 23, 34 or 62, 23, 34
Key Value
1 2
3 4
2 3
6 2
More than one value can be pointing to the same key but I need to store different 'chains' for each unique start and end point. The list could be in any order.
I'm using Java but am I bit stuck on how to tackle this problem.
Please help!