코딩테스트 풀이/JAVA
[프로그래머스/Lv.0] 문자열의 뒤의 n글자
무지맘
2023. 4. 24. 15:55
1. Input, Output, Example
- my_string의 뒤 n글자를 반환
2. Constraint
1) my_string은 숫자와 알파벳으로 이루어져 있다.
2) 1 ≤ my_string의 길이 ≤ 1,000
3) 1 ≤ n ≤ my_string의 길이
3. Code
1) 첫 코드(2023/04/24)
class Solution {
public String solution(String my_string, int n) {
return my_string.substring(my_string.length()-n,my_string.length());
}
}