2024-06-23发表2025-01-15更新LeetCode每日一题几秒读完 (大约83个字)0次访问520. 检测大写字母检测大写字母 难度: easy 原始链接: https://leetcode.cn/problems/detect-capital 标签: 模拟 解法一: 模拟go12345678910111213141516func detectCapitalUse(word string) bool { n := len(word) // true:大写;false:小写 fisrtUpper := word[0] <= 'Z' pre := false for i := 1; i < n; i++ { if i == 1 { pre = word[i] <= 'Z' continue } if pre != (word[i] <= 'Z') { return false } } return fisrtUpper || !fisrtUpper && !pre}520. 检测大写字母https://wuhunyu.top/leetcode/2024/06/detect-capital/index.html作者wuhunyu发布于2024-06-23更新于2025-01-15许可协议#模拟