Hey, you've probably already figured this out, but it looks like you're covering the same items when you do your search.
In a three-element vector you would compare: a == b, a == c.
Because you're starting the inner loop from zero, you're comparing: a == a, a == b, a == c, b == a, b == b, b ==...