
평등을 비교하기 위해 전후 정렬
import java.util.Arrays;
import java.util.stream.Collectors;
class Solution {
public int solution(String before, String after) {
String collect = Arrays.asList(before.split("")).stream().sorted()
.collect(Collectors.joining());
String collect1 = Arrays.asList(after.split("")).stream().sorted()
.collect(Collectors.joining());
return collect.equals(collect1) ? 1 : 0;
}
}
다른 사람의 솔루션
import java.util.Arrays;
class Solution {
public int solution(String before, String after) {
char() a = before.toCharArray();
char() b = after.toCharArray();
Arrays.sort(a);
Arrays.sort(b);
return new String(a).equals(new String(b)) ? 1 :0;
}
}