Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4ce5910

Browse files
add 2299
1 parentd02cab9 commit4ce5910

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-------------|-------------
11+
| 2299|[Strong Password Checker II](https://leetcode.com/problems/strong-password-checker-ii/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2299.java)|| Easy||
1112
| 2288|[Apply Discount to Prices](https://leetcode.com/problems/apply-discount-to-prices/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2288.java)|| Medium||
1213
| 2287|[Rearrange Characters to Make Target String](https://leetcode.com/problems/rearrange-characters-to-make-target-string/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2288.java)|| Easy||
1314
| 2284|[Sender With Largest Word Count](https://leetcode.com/problems/sender-with-largest-word-count/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2284.java)|| Medium||
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.HashSet;
4+
importjava.util.Set;
5+
6+
publicclass_2299 {
7+
publicstaticclassSolution1 {
8+
publicbooleanstrongPasswordCheckerII(Stringpassword) {
9+
if (password.length() <8) {
10+
returnfalse;
11+
}
12+
booleanhasLower =false;
13+
booleanhasUpper =false;
14+
booleanhasDigit =false;
15+
booleanhasSpecialChar =false;
16+
Set<Character>specialChars =newHashSet<>();
17+
specialChars.add('!');
18+
specialChars.add('@');
19+
specialChars.add('%');
20+
specialChars.add('^');
21+
specialChars.add('&');
22+
specialChars.add('*');
23+
specialChars.add('(');
24+
specialChars.add(')');
25+
specialChars.add('-');
26+
specialChars.add('+');
27+
specialChars.add('$');
28+
specialChars.add('#');
29+
for (inti =0;i <password.length();i++) {
30+
if (Character.isLowerCase(password.charAt(i))) {
31+
hasLower =true;
32+
}
33+
if (Character.isUpperCase(password.charAt(i))) {
34+
hasUpper =true;
35+
}
36+
if (Character.isDigit(password.charAt(i))) {
37+
hasDigit =true;
38+
}
39+
if (specialChars.contains(password.charAt(i))) {
40+
hasSpecialChar =true;
41+
}
42+
if (i >0 &&password.charAt(i) ==password.charAt(i -1)) {
43+
returnfalse;
44+
}
45+
}
46+
returnhasLower &&hasUpper &&hasDigit &&hasSpecialChar;
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp