package programmers;
public class 꼬리_문자열_Java_230831 {
public String solution(String [] str_list, String ex){
StringBuilder answer = new StringBuilder();
for(String str : str_list){
answer.append(str.contains(ex) ? "" : str);
}
return answer.toString();
}
public String solution_stream(String[] str_list, String ex) {
return Arrays.stream(str_list)
.filter(str -> !str.contains(ex))
.collect(Collectors.joining());
}
}
package programmers
import java.util.stream.Collectors
class 꼬리_문자열_Kotlin_230831 {
fun solution(strList: Array<String>, ex: String): String {
val answer = StringBuilder()
for (str in strList) {
answer.append(if (str.contains(ex)) "" else str)
}
return answer.toString()
}
fun solutionStream(strList: Array<String>, ex: String): String {
return strList.filter { !it.contains(ex) }
.joinToString("")
}
}
댓글
댓글 쓰기