public class Main {
public static void main(String[] args) {
Queue<String> que = new LinkedList<>();
que.add("red");
que.add("blue");
System.out.println(que.poll());
System.out.println(que.poll());
}
}
public class Main {
public static void main(String[] args) {
Queue<String> que = new LinkedList<>();
que.add("red");
que.add("blue");
System.out.println(que.peek());
System.out.println(que.peek());
}
}
3. Queue의 사용(연습문제)
아래의 문제를 보고 사용법을 익혀보자
https://do-hyeon.tistory.com/218
[LeetCode] 1700. Number of Students Unable to Eat Lunch
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circu..
do-hyeon.tistory.com
[Structure] Stack (Last In First Out) (0) | 2021.11.07 |
---|---|
[Structure] Array (배열) (0) | 2021.10.31 |