본문 바로가기

Coding Test/프로그래머스

[프로그래머스/자바] 크기가 작은 부분 문자열

class Solution {
    public int solution(String t, String p) {
        long target = Long.parseLong(p);
        
        int result = 0;
        
        for (int i = 0; i <= t.length() - p.length(); i++) {
            if (Long.parseLong(t.substring(i, i + p.length())) <= target) result++;
        }
        
        return result;
    }
}