File tree 1 file changed +27
-0
lines changed
August Challenge/com/leetcode/AugustChallenge/week1
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .leetcode .AugustChallenge .week1 ;
2
2
3
+ /*
4
+ https://leetcode.com/problems/detect-capital/
5
+ Given a word, you need to judge whether the usage of capitals in it is right or not.
6
+
7
+ We define the usage of capitals in a word to be right when one of the following cases holds:
8
+
9
+ All letters in this word are capitals, like "USA".
10
+ All letters in this word are not capitals, like "leetcode".
11
+ Only the first letter in this word is capital, like "Google".
12
+ Otherwise, we define that this word doesn't use capitals in a right way.
13
+
14
+
15
+ Example 1:
16
+
17
+ Input: "USA"
18
+ Output: True
19
+
20
+
21
+ Example 2:
22
+
23
+ Input: "FlaG"
24
+ Output: False
25
+
26
+
27
+ */
3
28
public class DetectCapital {
4
29
30
+ // Time Complexity :- O(n)
31
+ // Space Complexity :- O(1)
5
32
public boolean detectCapitalUse (String word ) {
6
33
int n = word .length ();
7
34
if (n == 1 )
You can’t perform that action at this time.
0 commit comments