Anagram / partial anagram detection algorithm finds incorrect answers
问题 I've written the following method to find out whether a long word contains a shorter word, and the order in which I pass the letters appears to effect the outcome. I've noticed that if I feed it absconds and bassy it correctly reports NO , but if I alphabetize the letters and give it abcdnoss and abssy , it gives YES . I'm not too sure why this is – can anyone spot the issue? - (BOOL) does: (NSString* ) longWord contain: (NSString *) shortWord { while([longWord length] > 0 && [shortWord