Skip to content

Commit

Permalink
Create Detect Capital.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayu-99 authored Jan 24, 2022
1 parent f67f99b commit 104a906
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Leetcode Challenge/January/Detect Capital.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Solution {
public:
bool detectCapitalUse(string word) {
if(isupper(word[0])){
if(isupper(word[1])){
for(int i=2;i<word.length();i++){
if(islower(word[i])){
return false;
}
}

}else{
for(int i=1;i<word.length();i++){
if(isupper(word[i])){
return false;
}
}
}

}else{
for(int i=0;i<word.length();i++){
if(isupper(word[i])){
return false;
}
}
}
return true;
}
};

0 comments on commit 104a906

Please sign in to comment.