this won't work since you're only considering the forward acquaintance not the backward in your first iteration, thus missing potentially the right celebrity. Assume you've got 5 persons, where 3 knows 2 but doesn't know 4 or 5 and 4 is the celebrity. your first loop will keep 3 as the candidate and will ignore 4 and 5. Then the final check will fail thus returning no success.