Skip to content

Commit dc01625

Browse files
authored
Merge pull request #61 from zzzyoonnn/main
[Solved] PRG_크기가 작은 부분문자열
2 parents 65ac9ca + f39a750 commit dc01625

File tree

1 file changed

+21
-0
lines changed
  • Week2/공통/크기가_작은_부분문자열

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package Week2.공통.크기가_작은_부분문자열;
2+
3+
public class jiyoon {
4+
class Solution {
5+
public int solution(String t, String p) {
6+
int answer = 0;
7+
int tl = t.length(); // 문자열 t의 길이
8+
int pl = p.length(); // 문자열 p의 길이
9+
10+
for (int i = 0; i < tl - pl + 1; i++) {
11+
// p의 길이가 18까지 가능하기 때문에, 이는 int의 범위를 벗어나므로 long 사용
12+
long num2 = Long.parseLong(t.substring(i, i + pl));
13+
long pnum = Long.parseLong(p);
14+
15+
if (num2 <= pnum) answer++;
16+
17+
}
18+
return answer;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)