Created
March 17, 2021 13:20
-
-
Save prestigegodson/188e57483741e725dc947aca3be45129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function first_repeating_character(characters) { | |
if (characters == undefined || characters.length == 0) { | |
return undefined; | |
} | |
let dict = {}; | |
for (i = 0; i < characters.length; i++) { | |
if (dict[characters.charAt(i)] == undefined) { | |
dict[characters.charAt(i)] = true; | |
} else { | |
return characters.charAt(i); | |
} | |
} | |
return undefined; | |
} | |
console.log(first_repeating_character("BACDEFGHIJBQWERUAAAA")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment