File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,26 @@ class Solution {
7171}
7272```
7373
74+ ### ** JavaScript**
75+
76+ ``` js
77+ /**
78+ * @param {string} astr
79+ * @return {boolean}
80+ */
81+ var isUnique = function (astr ) {
82+ let bitmap = 0 ;
83+ for (let i = 0 ; i < astr .length ; ++ i) {
84+ const pos = astr[i].charCodeAt () - ' a' .charCodeAt ();
85+ if ((bitmap & (1 << pos)) != 0 ) {
86+ return false ;
87+ }
88+ bitmap |= (1 << pos);
89+ }
90+ return true ;
91+ };
92+ ```
93+
7494### ** ...**
7595
7696```
Original file line number Diff line number Diff line change @@ -68,6 +68,26 @@ class Solution {
6868}
6969```
7070
71+ ### ** JavaScript**
72+
73+ ``` js
74+ /**
75+ * @param {string} astr
76+ * @return {boolean}
77+ */
78+ var isUnique = function (astr ) {
79+ let bitmap = 0 ;
80+ for (let i = 0 ; i < astr .length ; ++ i) {
81+ const pos = astr[i].charCodeAt () - ' a' .charCodeAt ();
82+ if ((bitmap & (1 << pos)) != 0 ) {
83+ return false ;
84+ }
85+ bitmap |= (1 << pos);
86+ }
87+ return true ;
88+ };
89+ ```
90+
7191### ** ...**
7292
7393```
Original file line number Diff line number Diff line change 1+ /**
2+ * @param {string } astr
3+ * @return {boolean }
4+ */
5+ var isUnique = function ( astr ) {
6+ let bitmap = 0 ;
7+ for ( let i = 0 ; i < astr . length ; ++ i ) {
8+ const pos = astr [ i ] . charCodeAt ( ) - 'a' . charCodeAt ( ) ;
9+ if ( ( bitmap & ( 1 << pos ) ) != 0 ) {
10+ return false ;
11+ }
12+ bitmap |= ( 1 << pos ) ;
13+ }
14+ return true ;
15+ } ;
You can’t perform that action at this time.
0 commit comments