// .假设有一个字符串aabcad,请写一段程序,去掉字符串中不相邻的重复字符串,既上述字符串处理之后的输出结果为:aabcd

NSMutableString *str = [[NSMutableString alloc] initWithFormat: @"aabcad"];

for (int i = 0; i < str.length - 1; i++) {
unsigned char s = [str characterAtIndex:i];
//从后面隔一个 开始
for (int j = i + 2; j < str.length; j++) {
if (s == [str characterAtIndex:j]) {
[str deleteCharactersInRange:NSMakeRange(j, 1)];
}
}
}
NSLog(@"删重后: %@",str);