728x90
링크
https://codingbat.com/prob/p183592
문제
코드
public String front22(String str) {
if(str.length()>=2){
String front = str.substring(0,2);
return front + str + front;
}
else{
return str+str+str;
}
}
public String front22(String str) {
// First figure the number of chars to take
int take = 2;
if (take > str.length()) {
take = str.length();
}
String front = str.substring(0, take);
return front + str + front;
}
728x90
'Algorithm > 기타(기업등)' 카테고리의 다른 글
[CodingBat/java] luckySum (0) | 2021.10.07 |
---|---|
[CodingBat/Java] countXX (0) | 2021.09.30 |
[CodingBat/Java] missingChar (0) | 2021.09.24 |
[SAP/C++] BST from postorder (0) | 2021.04.24 |
[SAP/C++] Mirror Tree (0) | 2021.04.24 |