728x90
문자열 앞의 n글자
class Solution {
fun solution(my_string: String, n: Int): String = my_string.slice(0 until n)
}
접두사인지 확인하기
class Solution {
fun solution(my_string: String, is_prefix: String): Int = if(my_string.startsWith(is_prefix)) 1 else 0
}
문자열 뒤집기
class Solution {
fun solution(my_string: String, s: Int, e: Int): String = my_string.replace(my_string.slice(s .. e), my_string.slice(s .. e).reversed())
}
세로 읽기
class Solution {
fun solution(my_string: String, m: Int, c: Int): String = (c-1 until my_string.length step m).map { my_string[it] }.joinToString("")
}
qr code
class Solution {
fun solution(q: Int, r: Int, code: String): String = (r until code.length step q).map { code[it] }.joinToString("")
}
728x90