BackhardQueue

Single Queue Digit Solution

Problem Statement

Given a queue of non-negative integers and an integer k, where all numbers in the queue repeat every k positions, find the number of unique digits in the queue.

Example 1
Input
{"queue":[1,1,2,2,3,3,4,4],"k":2}
Output
2

Explanation: Since digits repeat every 2 positions, we only need to consider unique digits at positions 0 and 1, which are 1 and 2 respectively.

Example 2
Input
{"queue":[5,5,5,5,5,5],"k":1}
Output
1

Explanation: Since all digits are the same, the entire queue has only 1 unique digit.

Constraints

  • 0 <= queue.length = k <= 2 * 10^9
  • 1 <= q, k <= 10000
  • 0 <= queue[i] <= 10^9
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free