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?
This is a discussion on Comparing vectors within the C++ Programming forums, part of the General Programming Boards category; How can I compare elements of two unordered vectors ? Where Code: vector A ( 1 2 3 4 5 ...
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?
If I have eight hours for cutting wood, I spend six sharpening my axe.
>> PS. What happened to all the old posts?
What happened
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.