Search
Duplicate
๐Ÿ“—

Detect Capital

์ฃผ์ฐจ
๋ฌธ์ œ๋ฒˆํ˜ธ
520
์–ธ์–ด
Swift
ํ‹ฐ์–ด
Easy
์œ ํ˜•
๋ฌธ์ž์—ด
nj_Blog
nj_์ƒํƒœ
์ดํ•ด๋„
100%
ํ’€์ด
์‚ฌ๋žŒ
์ดํ•ด๋„ 2
13 more properties

๋ฌธ์ œ์ ‘๊ทผ

โ€ข
๋ฌธ์ž์—ด ๊ธธ์ด ์ฒดํฌ
โ€ข
๋“ค์–ด์˜จ ๋ฌธ์ž์—ด๋“ค์˜ ๋Œ€๋ฌธ์ž ์ˆ˜ ์ฒดํฌ
โ€ข
3๊ฐ€์ง€ ์ผ€์ด์Šค์ธ์ง€ ํ™•์ธ(์†Œ๋ฌธ์ž๋งŒ ์žˆ๋Š”์ง€, ๋Œ€๋ฌธ์ž๊ฐ€ ํ•œ๊ฐœ๋งŒ ์žˆ๋Š”์ง€, ๋‹ค ๋Œ€๋ฌธ์ž์ธ์ง€)

๋†“์ณค๋˜ ๋ถ€๋ถ„

โ€ข
๋Œ€๋ฌธ์ž๊ฐ€ ํ•œ๊ฐœ๋งŒ ์žˆ๋Š” ๊ฒฝ์šฐ๋ฅผ ํŒ๋‹จํ• ๋•Œ ๊ฐœ์ˆ˜๋กœ๋งŒ ํŒ๋‹จํ• ๊ฒŒ ์•„๋‹ˆ๋ผ ์ฒซ๊ธ€์ž๋งŒ ๋Œ€๋ฌธ์ž์ธ์ง€๋ฅผ ํ™•์ธํ•ด์•ผํ•จ
โ—ฆ
ffffffffffF ์˜ ๊ฒฝ์šฐ ๋Œ€๋ฌธ์ž ๊ฐœ์ˆ˜๋กœ๋งŒ ํŒ๋‹จํ•˜๋ฉด true๋กœ ๋ฐ˜ํ™˜ํ•ด๋ฒ„๋ฆผ

์ฝ”๋“œ

14 MB

0 ms

class Solution { func detectCapitalUse(_ word: String) -> Bool { let wordLength = word.length var count = 0 for letter in word { if (letter >= "A" && letter <= "Z") { count += 1 } } switch count { case 0: return (true) case 1: if (word[word.startIndex] >= "A" && word[word.startIndex] <= "Z") { return (true) } return (false) case wordLength: return (true) default: return (false) } } }
Swift
๋ณต์‚ฌ
//๋‹ค๋ฅธ ์‚ฌ๋žŒ ํ’€์ด class Solution { func detectCapitalUse(_ word: String) -> Bool { var count = 0 for ch in word where ch.isUppercase { count += 1 } switch count { case 0, word.count: return true case 1: return word.first!.isUppercase default: return false } } }
Swift
๋ณต์‚ฌ