我有一系列的键值对.每个键有2个值.键的值可能相符. 最初,我从Key1开始,ValueKey1,ValueKey2存储在一个集中.(也许是数组). 现在,对于每个连续的Keyi,我检查Valuei,Valuei + 1是否在集合中.如果其中任何一个在集合中,请加入集合. 否则,如果两个KeyValue都存在于集合中,则丢弃该键. 我如何用C ++实现这个东西,我的想法很少,所以我建议如果可能的话,代码片段或提示会真的很有帮助.
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.
推荐答案A暗示?好的,我会给您一个提示,但是首先,请看我对问题的评论,并意识到您对问题的表述不清楚. 现在,有一个提示:您只需要实现集合理论操作(例如,union(析取)).只需通过该操作的定义 即可实现. 尝试一下,如果遇到任何问题,请向我们展示您的代码;如果您还解释您的困难所在,我们可能会为您提供帮助.
更多推荐
联合查找算法的实现
发布评论