반응형
https://school.programmers.co.kr/learn/courses/30/lessons/181943
class Solution {
public String solution(String my_string, String overwrite_string, int s) {
String answer = "";
answer = my_string.substring(0, s) + overwrite_string +
my_string.substring(s + overwrite_string.length(), my_string.length());
return answer;
}
}
class Solution {
public static String solution(String my_string, String overwrite_string, int s) {
String answer = "";
answer = my_string.substring(0, s) + overwrite_string +
my_string.substring(s + overwrite_string.length(), my_string.length());
return answer;
}
public static void main(String[] args) {
String my_string1 = "He11oWor1d";
String overwrite_string1 = "lloWorl";
int s1 = 2;
String solution1 = solution(my_string1, overwrite_string1, s1);
System.out.println(solution1);
String my_string2 = "Program29b8UYP";
String overwrite_string2 = "merS123";
int s2 = 7;
String solution2 = solution(my_string2, overwrite_string2, s2);
System.out.println(solution2);
}
}
반응형
'Portpolio > codingtest' 카테고리의 다른 글
Leetcode 344번 문자열 뒤집기 (1) | 2023.12.31 |
---|---|
Leetcode 125번 유효한 팰린드롬 (0) | 2023.12.31 |
프로그래머스 lv3. 단속카메라 java (0) | 2023.12.19 |
프로그래머스 lv0. QR Code java (1) | 2023.12.19 |
프로그래머스 lv0. 두 수의 합 java (0) | 2023.12.18 |
댓글