Solution 1) 내 풀이
class Solution {
    public int solution(String my_string, String is_prefix) {
        if (my_string.length() < is_prefix.length()) {
            return 0;
        } else {
            return is_prefix.contains(my_string.substring(0, is_prefix.length())) ? 1 : 0;
        }
    }
}
Solution 2) 다른 사람의 풀이_startsWith
class Solution {
    public int solution(String my_string, String is_prefix) {
        if (my_string.startsWith(is_prefix)) return 1;
        return 0;
    }
}
접미사 구하기의 endsWith와 같은 맥락

+ Recent posts