File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Time: O(l)
2
+ # Space: O(1)
3
+
4
+ # We define the usage of capitals in a word to be right when one of the following cases holds:
5
+ #
6
+ # All letters in this word are capitals, like "USA".
7
+ # All letters in this word are not capitals, like "leetcode".
8
+ # Only the first letter in this word is capital if it has more than one letter, like "Google".
9
+ # Otherwise, we define that this word doesn't use capitals in a right way.
10
+ # Example 1:
11
+ # Input: "USA"
12
+ # Output: True
13
+ # Example 2:
14
+ # Input: "FlaG"
15
+ # Output: False
16
+ # Note: The input will be a non-empty word consisting of uppercase and lowercase latin letters.
17
+
18
+ class Solution (object ):
19
+ def detectCapitalUse (self , word ):
20
+ """
21
+ :type word: str
22
+ :rtype: bool
23
+ """
24
+ return word .isupper () or word .islower () or word .istitle ()
You can’t perform that action at this time.
0 commit comments