File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
August Challenge/com/leetcode/AugustChallenge/week1 Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 11package com .leetcode .AugustChallenge .week1 ;
22
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+ */
328public class DetectCapital {
429
30+ // Time Complexity :- O(n)
31+ // Space Complexity :- O(1)
532 public boolean detectCapitalUse (String word ) {
633 int n = word .length ();
734 if (n == 1 )
You can’t perform that action at this time.
0 commit comments