Skip to content

Commit c9d716f

Browse files
authored
Create strong-password-checker-ii.py
1 parent f9f20ea commit c9d716f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Python/strong-password-checker-ii.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# string
5+
class Solution(object):
6+
def strongPasswordCheckerII(self, password):
7+
"""
8+
:type password: str
9+
:rtype: bool
10+
"""
11+
SPECIAL = set("!@#$%^&*()-+")
12+
return (len(password) >= 8 and
13+
any(c.islower() for c in password) and
14+
any(c.isupper() for c in password) and
15+
any(c.isdigit() for c in password) and
16+
any(c in SPECIAL for c in password) and
17+
all(password[i] != password[i+1] for i in xrange(len(password)-1)))

0 commit comments

Comments
 (0)