nbfuhao avatar

[LeetCode] Objective C — Check If a String Has Duplicate Characters

nbfuhao

Published: 06 Mar 2017 › Updated: 06 Mar 2017[LeetCode] Objective C — Check If a String Has Duplicate Characters

[LeetCode] Objective C — Check If a String Has Duplicate Characters

BOOL checkDuplicates(NSString *str)
{
     NSMutableArray *storageArray = [NSMutableArray array];
     for (int i = 0; i < str.length; i++) {
         NSString *charStr = [str substringWithRange:NSMakeRange(i,1)];
         if ([storageArray containsObject: charStr]) {
             return true;
         } else {
             [storageArray addObject: charStr];
         }
     }
     return false;
}

Leave [LeetCode] Objective C — Check If a String Has Duplicate Characters to:

Written by

Software Engineer, writing Swift and Objective codes

Read more #programming posts


Best Posts From nbfuhao

We have not curated any of nbfuhao's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From nbfuhao