-Code
class Solution {
public int solution(String t, String p) {
int answer = 0;
int pLen = p.length();
long pInt = Long.parseLong(p);
for (int i = 0; i <= t.length() - pLen; i++) {
long n = Long.parseLong(t.substring(i, i + pLen));
if (pInt >= n) answer++;
}
return answer;
}
}
'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
[프로그래머스/Java] 3진법 뒤집기 (0) | 2025.02.25 |
---|---|
[프로그래머스/Java] 예산 (0) | 2025.02.25 |
[프로그래머스/Java] 최대공약수와 최소공배수 (0) | 2025.02.25 |
[프로그래머스/Java] 같은 숫자는 싫어 (0) | 2025.02.25 |
[프로그래머스/Java] 직사각형 별찍기 (0) | 2025.02.25 |