class Solution {
public String solution(String[] str_list, String ex) {
String answer = "";
for(int i=0; i<str_list.length; i++) {
if(!str_list[i].contains(ex))
answer += str_list[i];
}
return answer;
}
}
이걸 하고 싶었는데! 놓친 게 Arrays라니 한참 멀었구만...
return Arrays.stream(strList)
.filter(s -> !s.contains(ex))
.collect(Collectors.joining());
이건 chatGPT 도움을 받은 코드.
아래의 코드가 안돼서 물어봤더니
return strList.stream()
.filter(s -> !s.contains(ex))
.collect(Collectors.joining());
▼ 이런 답안을 줬다.
return Stream.of(str_list)
.filter(s -> !s.contains(ex))
.collect(Collectors.toList())
.stream()
.collect(Collectors.joining());
'Study with me > 프로그래머스 L0 마스터하기' 카테고리의 다른 글
프로그래머스 - L0 배열비교하기 (0) | 2023.12.20 |
---|---|
프로그래머스 - L0 카운트다운 // IntStream.rangeClosed() (0) | 2023.12.19 |
프로그래머스 - L0 배열만들기1 (0) | 2023.12.18 |
프로그래머스 - L0 배열에서문자열대소문자변환하기 (0) | 2023.12.14 |
프로그래머스 - L0 이어붙인수 (0) | 2023.12.13 |