내 답안
class Solution {
public int solution(String myString, String pat) {
int answer = 0;
for(int i = myString.length()-1; i >= 0; i--){
String subStr = myString.substring(0, i + 1);
if(subStr.endsWith(pat)){
answer++;
}
}
return answer;
}
}
Java
복사
다른사람 풀이
class Solution {
public int solution(String myString, String pat) {
int cnt = 0;
for(int i=0; i<myString.length(); i++) {
if(myString.substring(i).startsWith(pat)){
cnt++;
}
}
return cnt;
}
}
Java
복사