Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7043489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:17:45+00:00 2026-05-28T02:17:45+00:00

I strugle with this for second day… I have an NSArray of ints, wrapped

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:17:46+00:00Added an answer on May 28, 2026 at 2:17 am

    You can use an NSMutableIndexSet as an efficient way to store a set of integers. Just iterate over the array, stuffing them in the NSMutableIndexSet, and then when you’re done, you can walk up the index set until you find a hole. Here’s an example:

    int lowestPositiveIntNotInArray(NSArray *array) {
        NSMutableIndexSet *set = [NSMutableIndexSet indexSet];
        for (NSNumber *num in array) {
            [set addIndex:[num intValue]];
        }
        // assuming 0 is a valid result here
        NSUInteger seed = [set firstIndex];
        if (seed > 0) {
            return 0;
        }
        NSUInteger next;
        while ((next = [set indexGreaterThanIndex:seed]) != NSNotFound) {
            if (next - seed > 1) {
                // there's a hole here
                break;
            }
            seed = next;
        }
        return seed+1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hawe all day strugle my head and i canot find any solution to
I again need help by you, this time I struggle with covariance, contravariance, delegates
I have the following code written to make my lazy second CPU core working.
I have a div, and I'm reloading it with Ajax every 1 second. And
Strugle with optimizing this subquery that count item: SELECT @crewid:=crewid AS `crewid`, COUNT(id) AS
I dynamically create gridview, and in this grid I have template field also field.HeaderTemplate
First of all, my apologies for the title of this question, I don't have
I always seem to have this internal struggle when it comes to user interface.
I'm not so hot with PowerShell yet, but have managed to get this command
Im new to linq so i still struggle .... I have a collection of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.