title: Writing function findEpidemics
body: <p>I need to make a function public Collection findEpidemics(List diagnoses, int k, int n) that determines if a disease is an epidemic, and returns a list of the diseases that are epidemic. We say a disease is an epidemic if it occurs more than n times during k consecutive days.
  The Diagnosis class is public Diagnosis(Disease disease, int day) and has functions getDisease() and getDay().</p>
  <p>The list diagnoses looks something like this:</p>
  <pre><code>Disease cholera = new Disease(&quot;cholera&quot;);
  Disease dengue = new Disease(&quot;dengue&quot;);
  List&lt;Diagnosis&gt; diagnoses = Arrays.asList(
  new Diagnosis(cholera, 0), // registered cholera on day 0
  new Diagnosis(cholera, 0),
  new Diagnosis(cholera, 1),
  new Diagnosis(dengue, 2),
  new Diagnosis(dengue, 2),
  // we have a gap here 
  new Diagnosis(cholera, 6),
  </code></pre>
  <p>So what I've done is making a hashmap collect that contains all the occurrences of the diseases for each day so it may for example look like this: {{cholera, 0}=2, {cholera, 1}=1, {dengue, 2}=2, {cholera, 6}=1}</p>
  <pre><code> public Collection&lt;String&gt; findEpidemics(List&lt;Diagnosis&gt; diagnoses, int k, int n) {
      
       // first we count occurrences 
       Map&lt;DiagnosisMetric, Long&gt; collect = diagnoses.stream().
              collect(Collectors.groupingBy(DiagnosisMetric::new, counting()));
      
     // check for epidemic 
     for(int i=0; i&lt;collect.size(); i++){
       for(int j=0; j&lt;k; j++){
            ???
      }
    }
  
  }
  </code></pre>
  <p>I'm kind of stuck on the part of checking if a disease is an epidemic so I'm stuck on how I can loop over the hashmap and check if the occurrence of a certain disease is more than n for those k consecutive days.</p>