File tree 3 files changed +55
-0
lines changed
3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,26 @@ class Solution {
71
71
}
72
72
```
73
73
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
+
74
94
### ** ...**
75
95
76
96
```
Original file line number Diff line number Diff line change @@ -68,6 +68,26 @@ class Solution {
68
68
}
69
69
```
70
70
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
+
71
91
### ** ...**
72
92
73
93
```
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