[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ๋ฌธ์์ด ๋ง๋ค๊ธฐ (์๋ฐ java)
1. ๋ฌธ์ : https://school.programmers.co.kr/learn/courses/30/lessons/12951?language=java
2. ํ์ด
๋ฐ๋ณต๋ฌธ ๋๋ฉด์ ๊ณต๋ฐฑ์ ๊ธฐ์ค์ผ๋ก ๋๋ฌธ์๋ก ๋ณํ
3. ์ฝ๋
class Solution {
public String solution(String s) {
String answer = "";
s = s.toLowerCase();
for(int i=0;i<s.length();i++){
char temp = s.charAt(i);
if(i==0){
if(Character.isDigit(temp)) answer += temp;
else answer += Character.toUpperCase(temp);
}
else{
if(s.charAt(i-1) == ' ') answer += Character.toUpperCase(temp);
else answer += temp;
}
}
return answer;
}
}
'๐ป Coding Problems Solving > Array | String | Loop' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ์ซ์์ ํํ (์๋ฐ java) (0) | 2022.11.26 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ์ด์ง๋ณํ๋ฐ๋ณตํ๊ธฐ (์๋ฐ java) (0) | 2022.11.26 |
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ์ต๋๊ฐ๊ณผ ์ต์๊ฐ (์๋ฐ java) (0) | 2022.11.24 |
[LeetCode] Product of Array Expect Self (0) | 2022.07.09 |
[LeetCode] Contains Duplicate (0) | 2022.07.09 |
์ต๊ทผ๋๊ธ