mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
15 lines
378 B
Java
15 lines
378 B
Java
public class DuplicateEncoder {
|
|
static String encode(String word) {
|
|
word = word.toLowerCase();
|
|
String result = "";
|
|
for (int i = 0; i < word.length(); i++) {
|
|
char character = word.charAt(i);
|
|
if (word.indexOf(character) != word.lastIndexOf(character)) {
|
|
result += ")";
|
|
} else {
|
|
result += "(";
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|