First Unique Character in a String
Mon Oct 20 2025 11:25:52 GMT+0000 (Coordinated Universal Time)
Saved by
@Inescn
public int findUniqueChar(String s) {
int uniqueCharIndex = -1;
for (int i = 0; i < s.length(); i++) {
boolean unique = true;
char currentChar = s.charAt(i);
for (int j = 0; j < s.length(); j++) {
if (currentChar == s.charAt(j) && i != j) {
unique = false;
break;
}
}
if (unique = true) {
uniqueCharIndex = 1;
break
}
}
return uniqueCharIndex;
}
content_copyCOPY
Comments