mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-06 17:44:10 +08:00
add: leetcode 0520 solution
This commit is contained in:
13
leetcode/0520.Detect-Capital/520.Detect Capital.go
Normal file
13
leetcode/0520.Detect-Capital/520.Detect Capital.go
Normal file
@ -0,0 +1,13 @@
|
||||
package leetcode
|
||||
|
||||
import "strings"
|
||||
|
||||
func detectCapitalUse(word string) bool {
|
||||
wLower := strings.ToLower(word)
|
||||
wUpper := strings.ToUpper(word)
|
||||
wCaptial := strings.ToUpper(string(word[0])) + strings.ToLower(string(word[1:]))
|
||||
if wCaptial == word || wLower == word || wUpper == word {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user