Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
int numOfStones = 0;
scanf("%d", &numOfStones);
NSMutableArray *stoneList = [NSMutableArray arrayWithCapacity:numOfStones];
for (int i=0; i<numOfStones; i++){
char composition[100];
scanf("%100s",composition);
NSString *str = [NSString stringWithCString:composition encoding:NSUTF8StringEncoding];
NSMutableSet *set = [NSMutableSet setWithCapacity:[str length]];
for (int i = 0; i< str.length; i++){
NSString *character = [str substringWithRange:NSMakeRange(i,1)];
[set addObject:character];
}
[stoneList addObject:set];
}
NSMutableSet *commenElements = [stoneList firstObject];
for (NSSet *set in stoneList){
[commenElements intersectSet:set];
}
printf("%lu",(unsigned long)[commenElements count]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.