๋ฐ์ํ
func solution(_ s: String) -> String {
var first = true
var res = ""
for c in s {
if c == " "{
res += " "
first = true
continue
}
if first {
if let test = Int(String(c)) {
res += String(c)
} else {
res += String(c).uppercased()
}
first = false
} else {
res += String(c).lowercased()
}
}
return res
}
์ฌ์ธ ์ค ์์๋๋ฐ ์๊ฐ๋ณด๋ค ๋งํ๋ค.
์ถ๊ฐํ๋ฉด ์ข์ ํ ์ผ
์ ๋ ฅ : " for the last week "
์ถ๋ ฅ: " For The Last Week "
๊ณต๋ฐฑ์ ๊ณ ๋ คํด์ผํด์ ๋ฐ๋ณต์ ๋๋ฉด์ first๋ณ์๋ก ์ฒซ๋จ์ด์ธ์ง ์ฒดํฌํ๋ค.
๋ฐ์ํ
'๐ ์ฝํ > ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] ํ๋ก๊ทธ๋๋จธ์ค92342 ์๊ถ๋ํ (0) | 2023.05.11 |
---|---|
[Swift] ํ๋ก๊ทธ๋๋จธ์ค118667 ๋ ํ ํฉ ๊ฐ๊ฒ ๋ง๋ค๊ธฐ (0) | 2023.05.11 |
[Swift] ํ๋ก๊ทธ๋๋จธ์ค150369 ํ๋ฐฐ๋ฐฐ๋ฌ๊ณผ ์๊ฑฐํ๊ธฐ (0) | 2023.05.10 |
[Swift] ํ๋ก๊ทธ๋๋จธ์ค150368 ์ด๋ชจํฐ์ฝ ํ ์ธํ์ฌ (0) | 2023.05.09 |
[Swift] ํ๋ก๊ทธ๋๋จธ์ค 12941 ์ต์๊ฐ ๋ง๋ค๊ธฐ (0) | 2023.05.06 |