First repeated character
Utilisateur anonyme
static char firstRepeating(char str[]) { // Creates an empty hashset HashSet h = new HashSet(); // Traverse the input array from left to right for (int i=0; i<=str.length-1; i++) { char c = str[i]; // HashSet add method returns a boolean false if already exisits if(! h.add(c)) { return c; } } return '\0'; }