File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ function findMissingLetter ( str : string ) : string {
2+ let hashMap = new Map < string , boolean > ( )
3+
4+ for ( const char of str ) {
5+ if ( hashMap . has ( char ) ) {
6+ continue
7+ }
8+ hashMap . set ( char , true )
9+ }
10+
11+ const alphabet : string = 'abcdefghijklmnopqrstuvwxyz'
12+ for ( const letter of alphabet ) {
13+ if ( ! hashMap . has ( letter ) ) {
14+ return letter
15+ }
16+ }
17+ return 'No missing letter found'
18+ }
Original file line number Diff line number Diff line change 1+ function returnFirstNonDuplicated ( str : string ) : string {
2+ const hashMap = new Map < string , boolean > ( )
3+
4+ for ( const char of str ) {
5+ if ( hashMap . has ( char ) ) {
6+ hashMap . set ( char , false )
7+ } else {
8+ hashMap . set ( char , true )
9+ }
10+ }
11+
12+ for ( const [ char , isUnique ] of hashMap ) {
13+ if ( isUnique ) {
14+ return char ;
15+ }
16+ }
17+ return 'No non-duplicated character found'
18+ }
You can’t perform that action at this time.
0 commit comments