I have a series of Key value pairs. Each Key has 2 values. Values of Keys ma coincide.
Initially i start with Key1, ValueKey1, ValueKey2 are stored in a set.(Maybe Array).
Now for each consecutive Keyi, i check if Valuei, Valuei+1 are in the set. If any one of them is in the set, then join the set.
Else if both KeyValues are present in a set, discard that key .
How can i implement this thing using C++, i have very less idea, so i would suggest if possible a code snippet or a hint would be really helpful.