Return the number of elements in a queue (array). This is the size/length of the array.
Example Input & Output
Example 1
Input
[1,2,3]
Output
3
Explanation
Three elements
Example 2
Input
[]
Output
0
Explanation
Empty
Example 3
Input
[5]
Output
1
Explanation
Single
Example 4
Input
[0]
Output
1
Explanation
Zero is still an element
Example 5
Input
[10,20,30,40,50]
Output
5
Explanation
Five elements
Algorithm Flow

Recommendation Algorithm Flow for Queue Size
Solution Approach
Best Answers
java
class Solution {
public int solution(int[] nums) {
return nums.length;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
