Java Dequeue in Java : Hacker Rank Solution : Digit Wood

Java
,

In computer science, a double-ended queue (dequeue, often abbreviated to deque, pronounced deck) is an abstract data type that generalizes a queue, for which elements can be added to or removed from either the front (head) or back (tail).

Deque interfaces can be implemented using various types of collections such as LinkedList or ArrayDeque classes. For example, deque can be declared as:

You can find more details about Deque here.

In this problem, you are given N integers. You need to find the maximum number of unique integers among all the possible contiguous subarrays of size M.

Note: Time limit is 3 second for this problem.

Input Format

The first line of input contains two integers N and M: representing the total number of integers and the size of the subarray, respectively. The next line contains N space separated integers.

Output Format

Print the maximum number of unique integers among all possible contiguous subarrays of size M.

Sample Input

Sample Output

SOLUTION : –

FOLLOW FOR MORE QUESTIONS AND SOLUTIONS | DIGIT WOOD

Leave a Reply

Your email address will not be published. Required fields are marked *