Given an array representing a queue and a value, add the value to the back (end) of the queue.
Example Input & Output
Example 1
Input
[1,2,3],4
Output
[1,2,3,4]
Example 2
Input
[10,20],30
Output
[10,20,30]
Example 3
Input
[1],2
Output
[1,2]
Example 4
Input
[],5
Output
[5]
Example 5
Input
([],[],[1,2,3])
Output
[1,2,3]
Algorithm Flow

Recommendation Algorithm Flow for Queue Push Back
Solution Approach
Best Answers
java
import java.util.*;
class Solution {
public int[] solution(int[] nums, int val) {
int[] r=Arrays.copyOf(nums,nums.length+1);
r[r.length-1]=val;
return r;
}
}Related Queue Challenges
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
