title: How to find max number of participant who can perform?
body: <p>I am trying to solve a question which has the following description:</p>
  <p>At a time only one person can perform on the stage and arrival time and duration of each participant is given in the form of an array. Find the max number of participants who can perform.</p>
  <p>Example:</p>
  <blockquote>
  <p>arrival time: [1,3,3,5,7]</p>
  <p>duration: [2,2,1,2,1]</p>
  <p>answer would be 4, as 1-3; 3-5 or 3-4; 5-7; 7-8</p>
  </blockquote>
  <p>So from this, I can find the exit time of each participant. How do I find max number of events possible, when there is overlap in timings.</p>
  <p>The code I have tried is:</p>
  <pre><code>int count = 1;
          
  for(int i=0;i&lt;entry.size()-1;i++) {
      if(entry.get(i) &lt; exit.get(i+1)) {
          count++;
      }
  }
          
  return count;
  </code></pre>
  <p>I found the exit list using arrival + duration, but many tests are failing. The above example passes, but there might be instances where the overlapping time may have more participants possible.</p>
  <p>I am not able to figure out how to proceed.</p>