Skip to content

Instantly share code, notes, and snippets.

@MohammedALREAI
Created February 28, 2021 11:24
Show Gist options
  • Save MohammedALREAI/a2323a31eafab841e4c7f032c650d756 to your computer and use it in GitHub Desktop.
Save MohammedALREAI/a2323a31eafab841e4c7f032c650d756 to your computer and use it in GitHub Desktop.
firstNotRepeatingCharacter typescript
interface Imap{
[key:string]:number
}
function firstNotRepeatingCharacter(s: string="abacabad"): string {
let map:Imap ={}
for (let e of s){
if(e in map){
map[e]=map[e]+1
}
else
map[e]=1
}
for (let e in map)
if (map[e] == 1)
return e
return '_'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment