원본 : https://school.programmers.co.kr/learn/courses/30/lessons/159994
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
풀이
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
class Solution {
public String solution(String[] cards1, String[] cards2, String[] goal) {
String answer = "Yes";
Queue<String> cards1Queue = new LinkedList<>(Arrays.asList(cards1));
Queue<String> cards2Queue = new LinkedList<>(Arrays.asList(cards2));
for (String str : goal) {
if (str.equals(cards1Queue.peek())) {
cards1Queue.poll();
} else if (str.equals(cards2Queue.peek())) {
cards2Queue.poll();
} else {
answer = "No";
break;
}
}
return answer;
}
}
대충 만든 자판 (연습문제) (0) | 2023.05.02 |
---|---|
덧칠하기 (연습문제) (0) | 2023.04.28 |
둘만의 암호 (연습문제) (0) | 2023.04.28 |
바탕화면 정리 (연습문제) (0) | 2023.04.28 |
공원 산책 (연습문제) (0) | 2023.04.28 |
댓글 영역