๋ฌธ์ ๐ฝ
https://school.programmers.co.kr/learn/courses/30/lessons/159994
๋ค๋ฅธ์ฌ๋ ํ์ด ๐ฝ
function solution(cards1, cards2, goal) {
for(const s of goal) {
if(cards1[0] == s) {
cards1.shift();
} else if(cards2[0] == s) {
cards2.shift();
} else {
return "No"
}
}
return "Yes";
}
๋ดํ์ด๐ฝ
1. ์ฑ๊ณต โญ
function solution(cards1, cards2, goal) {
var answer = "Yes";
for(let i=0; i<goal.length; i++){
if(goal[i]===cards1[0]){
cards1.shift();
}else if(goal[i]===cards2[0]){
cards2.shift()
}else{
answer="No"
break;
}
}
return answer;
}
๋๋์ ๐ฝ
์ด๋ ต์ง ์๊ฒ ํ ์ ์์๋ค!