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!
Create a set of substrings for each string. Then do an intersection of the two sets to find the common substrings.