I was thinking about an element being duplicated a number of times in one of the arrays but not in the other array but I now see that this will depend on how you define "all" in the original question. I understood it as "all duplicates are alike", but if you understand it as "all duplicates are different" then your program works (but all hash-based solutions are broken unless they keep an explicit tally of the number of each individual element).
My solution suffers from the same "defect" as yours depending on whether or not you increment the index of the second array after you have found a match. If you don't increment the index, then duplicates are not relevant.
Update: Fixed some typos.
Thanks L~R for this insight.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
In reply to Re: Re: Re: Array lookup
by CountZero
in thread Array lookup
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |