如何在不使用数组的情况下执行此操作?我有这个实现,但我需要不使用数组,位操作和任何其他C/C++库.
bool IsCharDuplication(string s) {
bool result = false;
bool controlArray[256];
for (int i = 0; i < s.length(); i++) {
int val = s[i];
if (controlArray[val] == true) {
result = true;
break;
}
controlArray[val] = true;
}
return result;
}
Run Code Online (Sandbox Code Playgroud)