-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path520.py
22 lines (20 loc) · 872 Bytes
/
520.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
__________________________________________________________________________________________________
sample 24 ms submission
class Solution:
def detectCapitalUse(self, word: str) -> bool:
c = 0
for i in word:
if i.isupper():
c += 1
return len(word) == c or c == 0 or (c == 1 and word[0].isupper())
__________________________________________________________________________________________________
sample 13036 kb submission
class Solution:
def detectCapitalUse(self, word: str) -> bool:
count = 0
for char in word:
if char.isupper():
count += 1
n = len(word)
return count == 0 or count == n or (count == 1 and word[0].isupper())
__________________________________________________________________________________________________