public static void removeDuplicates(char[] str) {
if (str == null) return;
int len = str.length;
if (len < 2) return;
int tail = 1;
for (int i = 1; i < len; ++i) {
int j;
for (j = 0; j < tail; ++j) {
if (str[i] == str[j]) break;
}
if (j == tail) {
str[tail] = str[i];
++tail;
}
}
str[tail] = 0;
}
Home
Coding Challenge
Technology
Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer.
Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer.
Share This
Tags
# Coding Challenge
# Technology
Share This
About BunksAllowed
Technology
Labels:
Coding Challenge,
Technology
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.