回分類題庫
d296: (1052cp2_ex2) Detect Capital
出處:LeetCode

Difficulity : 1
Accepted : 70 Times | Submit :310 Times | Clicks : 788
Accepted : 63 Users | Submit : 67 Users | Accepted rate : 94%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2017-03-01 23:03

Content :

Given a word, you need to judge whether the usage of capitals in it is right or not.

We define the usage of capitals in a word to be right when one of the following cases holds:

  1. All letters in this word are capitals, like "USA".
  2. All letters in this word are not capitals, like "leetcode".
  3. Only the first letter in this word is capital if it has more than one letter, like "Google".

Otherwise, we define that this word doesn't use capitals in a right way.

 
You can start your code from here...
 
void detectCapitalUse(char* word) {
    
}

Input :

Input: "USA"

Output :

Output: True

Sample Input :

USA
FlaG

Sample Output :

True
False

Hint :


  

Author :

LeetCode (管理員:cp2ta)

  Solve it!   Status Forum (0)

C++
C
JAVA
78847. nccucs105703021 (7 ms , 216KB)
79593. cs0909 (8 ms , 186KB)
79592. cs0909 (8 ms , 193KB)
79591. cs0909 (8 ms , 196KB)
79523. nccucs105703028 (8 ms , 194KB)
78808. nccucs105703029 (2 ms , 188KB)
79435. nccucs105703025 (4 ms , 185KB)
79412. nccucs105703032 (4 ms , 193KB)
78880. nccucs105703038 (4 ms , 188KB)
78786. nccucs105703005 (4 ms , 191KB)
89346. nwgs524513cja (94 ms , 220KB)
89345. nwgs524513cja (113 ms , 212KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡