Input:
S = "geeksforgeeks"
Output: g
Explanation: g, e, k and s are the repeating
characters. Out of these, g occurs first.
const repeatedCharacter = (str) => {
for (let i = 0; i < str.length - 1; i++) {
for (let j = i + 1; j < str.length; j++) {
if (str[i] === str[j]) {
return str[i];
}
}
}
return -1
};
console.log(repeatedCharacter("geeksforgeeks"));