title: Write an algorithm to find if user logged in more than 4 times in 30 days?
body: <p>Suppose you're given sorted timestamps of when User's Login time as array of dates. Find if user logged in more than 4 times in any 30 days.</p>
  
  <p>Example 1:<br>
  Array of dates =<br>
  1 Jan 12am, 2 jan 12 am, 3 jan 12 am, 4 jan 12 am, 9 feb 12 am</p>
  
  <p>Answer will be no</p>
  
  <p>Example 2:<br>
  Array of dates =<br>
  1 Jan 12am, 2 jan 12 am, 3 jan 12 am, 4 jan 12 am, 5 jan 12 am  </p>
  
  <p>Answer will be yes</p>
  
  <p>I am just looking for pseudo code or algorithm for this problem. Not actual code</p>
  
  <p>My solution</p>
  
  <pre><code>   Consider sorted array of n dates
      Iterate thru 0..n-1 consider value as i {
          Iterate thru i+1 till n-1 {
          if arr[j] is within 30 days of arr[i] then loginCount++
          else break;
          if(loginCount == 4)
              return Yes
      }}
      return No;
  </code></pre>