Skip to content

Commit

Permalink
Time: 0 ms (100.00%), Space: 1.9 MB (81.01%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
jonghyeons committed Jan 2, 2023
1 parent e071ec3 commit 4284a7c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions 0520-detect-capital/0520-detect-capital.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
func detectCapitalUse(word string) bool {
if word[0] >= 65 && word[0] <= 90 {
if len(word) == 1 {
return true
}

if word[0] >= 65 && word[1] <= 90 {
for i := 1; i < len(word); i++ {
if word[i] >= 97 && word[i] <= 122 {
return false
}
}
} else {
for i := 1; i < len(word); i++ {
if word[i] >= 65 && word[i] <= 90 {
return false
}
}
}
} else {
for i := 1; i < len(word); i++ {
if word[i] >= 65 && word[i] <= 90 {
return false
}
}
}
return true
}

0 comments on commit 4284a7c

Please sign in to comment.