How can I compare elements of two unordered vectors ?
Whereis the same asCode:vector A ( 1 2 3 4 5 }.Code:vector B { 1 4 2 5 3 }
PS. What happened to all the old posts?
How can I compare elements of two unordered vectors ?
Whereis the same asCode:vector A ( 1 2 3 4 5 }.Code:vector B { 1 4 2 5 3 }
PS. What happened to all the old posts?
sort them before comparing?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
>> PS. What happened to all the old posts?
http://cboard.cprogramming.com/showthread.php?t=87796
If you don't want to sort them, you could use an array of piles or a map, then read the first vector, increment the counter for each element respectively, then read the second vector, decrement the counter for each element and see if all the counters are zero at the end.