I strugle with this for second day…
I have an NSArray of ints, wrapped as NSNumbers. I need to find the lowest positive int, that is not present in the array.
I strugle with this for second day… I have an NSArray of ints, wrapped
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use an
NSMutableIndexSetas an efficient way to store a set of integers. Just iterate over the array, stuffing them in theNSMutableIndexSet, and then when you’re done, you can walk up the index set until you find a hole. Here’s an example: