How can i find Set of Unique Elements In 2d Vector in most EFFICIENT WAY??
Vector Declaration :
vector <int> par[100000];
Example :
Input :
1,2,3,4
1,4,3,2
1,2,3,4
5,4,2,9
8,6,5,4
1,2,3,4
Output :
1,2,3,4
1,4,3,2
5,4,2,9
8,6,5,4
How can i find Set of Unique Elements In 2d Vector in most EFFICIENT WAY??
Vector Declaration :
vector <int> par[100000];
Example :
Input :
1,2,3,4
1,4,3,2
1,2,3,4
5,4,2,9
8,6,5,4
1,2,3,4
Output :
1,2,3,4
1,4,3,2
5,4,2,9
8,6,5,4
Do you want to perform some operations on the resultant 2D matrix? How about inserting them in a set of vectors.
I guess you want a more efficient way compared to NlogN.(N is the unique number of elements in set). Still thinking an efficient way.
You can make trie type structure or you can also use unordered map…
For trie type structure, at each level you would store a column in sorted manner and insert and find element accordingly… This link may help.
1 5 8
2 4 4 6
3 3 2 5
4 2 9 4
This is how your trie will look like… Hope this will help…
Thanks!!!
Thanks!!
Learned something new!!