public String solution(String[] cards1, String[] cards2, String[] goal) {
int one = 0;
int two = 0;
for (String g : goal) {
if (one < cards1.length && g.equals(cards1[one])) {
one++;
} else if (two < cards2.length && g.equals(cards2[two])) {
two++;
} else {
return "No";
}
}
return "Yes";
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/159994