내 답안
class Solution {
public int[] solution(String myString) {
String[] splitArr = myString.split("x", myString.length());
int[] answer = new int[splitArr.length];
for (int i = 0; i < splitArr.length; i++) {
answer[i] = splitArr[i].length();
}
return answer;
}
}
Java
복사
다른사람 풀이
import java.util.Arrays;
class Solution {
public int[] solution(String myString) {
return Arrays.stream(myString.split("x", myString.length()))
.mapToInt(x -> x.length())
.toArray();
}
}
Java
복사