mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 19:19:07 +01:00
16 lines
378 B
Java
16 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;
|
||
|
}
|
||
|
}
|