First Recuring Character

Run Settings
LanguageJavaScript
Language Version
Run Command
//Brute force method function firstRecuringCharacter(input){ for(let i=0;i<input.length;i++){ for(let j=i-1;j>=0;j--){ if(input[j]===input[i]){ return input[i] } } } return undefined } //Optimal Solution using Hash Table function firstRecuringCharacter1(input){ let map={}; for(let i=0;i<input.length;i++){ if(map[input[i]]!=undefined){ return input[i] }else{ map[input[i]]=i } } return undefined } firstRecuringCharacter1([1,1,3,3])
Editor Settings
Theme
Key bindings
Full width
Lines