title: Find the time for more than K customers present in the hotel
body: <p>if there are more than K customers present in the hotel at any given moment ,then period of time is called P period.</p>
  <p><strong>Task is to determine the P period</strong></p>
  <p>Input format
  first line contains n and k and next n lines contain check-in and check-out time of the ith customer
  Test Case:</p>
  <pre><code>3 2
  5 8
  2 4
  3 9
  </code></pre>
  <p>Output:4</p>
  <p>If I am not wrong we have to find the time at which more than K customers present at the moment.
  my code</p>
  <pre><code>def hotel(n,k,A):
      count=0
      dp=[1]*n
      for i in range(n):
          I1=A[i][0]
          o1=A[i][1]
          time=[]
          for j in range(i+1,n):
              I2=A[j][0]
              o2=A[j][1]
              if I1&gt;=I2 and I1&lt;o2:
                  dp[i]=dp[i]+1
                  if o1&lt;=o2:
                      time.append(o1-I1)
                  else:
                      time.append(o2-I1)
              elif I1&lt;I2 and o1&gt;I2:
                  dp[i]=dp[i]+1
                  if o1&gt;o2:
                      time.append(o2-I2)
                  else:
                      time.append(o1-I2)
          if dp[i]&gt;=k:
              count+=sum(time)
      return count
  </code></pre>
  <p>Problem it showing wrong answer with code
  can anyone help.</p>