c# - nested hashset of lists? -
i'm working on 1 of project euler problems, , wanted take approach of creating list of values, , adding list hashset, way evaluate in constant time if list exists in hashset, end goal count number of lists in hashset end result.
the problem i'm having when create list in manner.
hashset<list<int>> finallist = new hashset<list<int>>(); list<int> candidate = new list<int>(); candidate.add(5); finallist.add(candidate); if (finallist.contains(candidate) == false) finallist.add(candidate); candidate.clear(); //try next value
obviously finallist[0]
item cleared when clear candidate , not giving me desired result. possible have hashset of lists(of integers) this? how ensure new list instantiated each time , added new item hashset, perhaps in loop testing many values , possible list combinations?
why don't use value unique each list key or identifier? create hashset keys unlock lists.
Comments
Post a Comment