File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 185
185
| 2283| [ 判断一个数的数字计数是否等于数位的值] ( https://leetcode.cn/problems/check-if-number-has-equal-digit-count-and-digit-value/ ) | [ JavaScript] ( ./algorithms/check-if-number-has-equal-digit-count-and-digit-value.js ) | Easy|
186
186
| 2287| [ 重排字符形成目标字符串] ( https://leetcode.cn/problems/rearrange-characters-to-make-target-string/ ) | [ JavaScript] ( ./algorithms/rearrange-characters-to-make-target-string.js ) | Easy|
187
187
| 2293| [ 极大极小游戏] ( https://leetcode.cn/problems/min-max-game/ ) | [ JavaScript] ( ./algorithms/min-max-game.js ) | Easy|
188
+ | 2299| [ 强密码检验器 II] ( https://leetcode.cn/problems/strong-password-checker-ii/ ) | [ JavaScript] ( ./algorithms/strong-password-checker-ii.js ) | Easy|
188
189
| 面试题 04.12| [ 面试题 04.12. 求和路径] ( https://leetcode.cn/problems/paths-with-sum-lcci/ ) | [ JavaScript] ( ./algorithms/paths-with-sum-lcci.js ) | Medium|
189
190
| 面试题 02.07| [ 面试题 02.07. 链表相交] ( https://leetcode.cn/problems/intersection-of-two-linked-lists-lcci/ ) | [ JavaScript] ( ./algorithms/intersection-of-two-linked-lists-lcci.js ) | Easy|
190
191
| 剑指 Offer 05. 替换空格| [ 剑指 Offer 05. 替换空格] ( https://leetcode.cn/problems/ti-huan-kong-ge-lcof/ ) | [ JavaScript] ( ./algorithms/ti-huan-kong-ge-lcof.js ) | Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2299. 强密码检验器 II
3
+ * @param {string } password
4
+ * @return {boolean }
5
+ */
6
+ var strongPasswordCheckerII = function ( password ) {
7
+ if ( password . length < 8 ) return false ;
8
+ let lowerCaseFlag = false ;
9
+ let upperCaseFlag = false ;
10
+ let digitFlag = false ;
11
+ let specialCharFlag = false ;
12
+
13
+ const isLowerCase = ( c ) => c >= "a" && c <= "z" ;
14
+ const isUpperCase = ( c ) => c >= "A" && c <= "Z" ;
15
+ const isNumber = ( c ) => c >= "0" && c <= "9" ;
16
+ const specialSet = new Set ( "!@#$%^&*()-+" ) ;
17
+
18
+ let perv = "" ;
19
+
20
+ for ( let i = 0 ; i < password . length ; i ++ ) {
21
+ let char = password [ i ] ;
22
+
23
+ if ( perv === char ) {
24
+ return false ;
25
+ }
26
+ perv = char ;
27
+
28
+ if ( isLowerCase ( char ) ) {
29
+ lowerCaseFlag = true ;
30
+ }
31
+ if ( isUpperCase ( char ) ) {
32
+ upperCaseFlag = true ;
33
+ }
34
+ if ( isNumber ( char ) ) {
35
+ digitFlag = true ;
36
+ }
37
+ if ( ! specialCharFlag && specialSet . has ( char ) ) {
38
+ specialCharFlag = true ;
39
+ }
40
+ }
41
+
42
+ return lowerCaseFlag && upperCaseFlag && digitFlag && specialCharFlag ;
43
+ } ;
You can’t perform that action at this time.
0 commit comments