Git Product home page Git Product logo

codes's Introduction

Codes

My first program on github!! Question: 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:

Deque deque = new LinkedList<>(); or Deque deque = new ArrayDeque<>(); 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.

Constraints 1<=N<=100000 1<=M<=100000 M<=N

The numbers in the array will range between[0,10000000] .

Output Format

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

Sample Input

6 3 5 3 5 2 3 2 Sample Output

3 Explanation

In the sample testcase, there are 4 subarrays of contiguous numbers. s1=<5,3,5> - Has 2 unique numbers s2=<3,5,2> - Has 3 unique numbers s3=<5,2,3> - Has 3 unique numbers s4=<2,3,2> - Has 2 unique numbers In these subarrays, there are 2,3,3,2 unique numbers, respectively. The maximum amount of unique numbers among all possible contiguous subarrays is 3.

x------------------------------x--------------------------------------xx------------------------------------------x--------------------------------------------x

codes's People

Contributors

gravewalker00 avatar silverdragon12 avatar driftmaniacc avatar githarsh009 avatar jc8223 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.