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 8776959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:10:54+00:00 2026-06-13T19:10:54+00:00

I have been struggling with a problem for the last 2 days and was

  • 0

I have been struggling with a problem for the last 2 days and was wondering if the community could help out. I have a NSString of numbers and I need to compare how many numbers match the amount of numbers in another string.

Example:

     String 1: 14523 25623 651 88

     String 2: 9123 88 14523 333

Based on these 2 strings, we can see that they both contain “88” and “14523”. So there are 2 matches. I don’t know how to figure out this comparison via code.

I have thought of simply having a substring to break up string 1 and compare each value to string 2 but this is very inefficient. I believe there is a better way.

Can anyone offer any advice? An example would be extremely appreciated. Thank you!

  • 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-06-13T19:10:55+00:00Added an answer on June 13, 2026 at 7:10 pm

    Create a set of substrings for each string. Then do an intersection of the two sets to find the common substrings.

    NSString *string1 = @"14523 25623 651 88";
    NSString *string2 = @"9123 88 14523 333";
    NSSet *setA = [NSSet setWithArray:[string1 componentsSeparatedByString:@" "]];
    NSSet *setB = [NSSet setWithArray:[string2 componentsSeparatedByString:@" "]];
    NSMutableSet *common = [setA mutableCopy];
    [common intersectSet:setB];
    NSLog(@"common substrings = %@", common);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been struggling for a few days trying to find out how come
For the last couple of days of my X-mas holidays, I have been struggling
I have been struggling with a problem for a couple of days now with
I have a problem that I have been struggling with for a few days
I have been struggling with this problem for a few days now and I
I have been struggling with this problem for the last few hours, and it
I have been struggling with this problem for a while now, so any help
I have been struggling with this problem, read many questions, articles but could not
I have been struggling with a problem for the past days in a Ruby
For the last couple of days I have been struggling with the following issue

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.