Skip to content

Commit 4ce5910

Browse files
add 2299
1 parent d02cab9 commit 4ce5910

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+
package com.fishercoder.solutions;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class _2299 {
7+
public static class Solution1 {
8+
public boolean strongPasswordCheckerII(String password) {
9+
if (password.length() < 8) {
10+
return false;
11+
}
12+
boolean hasLower = false;
13+
boolean hasUpper = false;
14+
boolean hasDigit = false;
15+
boolean hasSpecialChar = false;
16+
Set<Character> specialChars = new HashSet<>();
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 (int i = 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+
return false;
44+
}
45+
}
46+
return hasLower && hasUpper && hasDigit && hasSpecialChar;
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy