class Node{
int data;
Node next;
public Node(int data){
this.data = data;
}
}
public class MyQueue {
public Node head;
public Node tail;
int useSize;
public void offer(int data){
if(head == null){
this.head = new Node(data);
this.tail = head;
useSize++;
}
else {
this.tail.next = new Node(data);
this.tail = this.tail.next;
useSize++;
}
}
public int poll(){
if(this.head == null){
return -1;
}
int oldData = head.data;
this.head = this.head.next;
useSize--;
return oldData;
}
public int peek(){
if(this.head == null){
return -1;
}
return this.head.data;
}
public int size(){
return useSize;
}
}